define(".", [ "static_v4/style/style.css", "static_v4/style/quanpei.css", "static_v4/js/minJS/commonPlug/commonPlug.min", "static_v4/js/minJS/jrollPullDownPlug/jrollPullDownPlug.min", "static_v4/js/mod/addcar_quick", "static_v4/js/mod/public", "static_v4/js/mod/shopCar_list_sea", "static_v4/js/mod/sum", "static_v4/js/mod/goodsSize_selet", "static_v4/js/mod/visualAreaInfo", "static_v4/js/mod/baiduCount" ], function(require, exports, module) {
    require("static_v4/style/style.css");
    require("static_v4/style/quanpei.css");
    require("static_v4/js/minJS/commonPlug/commonPlug.min");
    require("static_v4/js/minJS/jrollPullDownPlug/jrollPullDownPlug.min");
    require("static_v4/js/mod/addcar_quick");
    var OIndexSea = require("static_v4/js/mod/shopCar_list_sea");
    module.exports = {
        init: function(data, name) {
            OIndexSea.init(data, name);
        }
    };
    require("static_v4/js/mod/baiduCount");
});
define("static_v4/js/mod/shopCar_list_sea", [ "./public", "./sum", "./goodsSize_selet", "./visualAreaInfo" ], function(require, exports, module) {
    var myPub = require("./public");
    var SumEvent = require("./sum");
    var GoodsSizeEvent = require("./goodsSize_selet");
    // 曝光可视区域元素
    var visualArea = require("./visualAreaInfo");
    var oWindow = $(window);
    var oWrap = $(".js_wrap");
    var oHeader = $(".js_headerBox");
    // 头部
    var oFooter = $(".js_footer");
    // 底部
    var oContain = $(".js_contain");
    // 主体
    var oEmptyCar = $(".js_emptyCar");
    // 购物车为空
    var oStoreEditBtn = $(".js_storeEdit");
    // 编辑按钮
    var oAllseletBtn = $(".js_btnAllselet");
    // 全部选按钮
    var oAllCheck = oAllseletBtn.find(".js_checkBoxArea");
    // 全选选框
    var oSumPrice = $(".js_sumPrice");
    // 总价格
    var nOrderNum = $(".js_orderNum");
    // 订单数量
    var oBtnConfirm = $(".js_btnConfirm");
    // 结算按钮
    var oBtnAllDel = $(".js_btnAllDel");
    // 删除按钮
    var oScrollPage = $(".js_scrollPage");
    // 滚动页面
    var oShopCarGoods = $(".js_shopCarGoods");
    var oTaxSum = $(".js_taxSum");
    // 总的税费
    var oTaxDelCar = $(".js_taxDelCar");
    // 税费区域
    var oTaxAll = $(".js_taxAll");
    // 计算总的税费区域
    var oSideBox = $(".js_sideBox");
    // 侧边按钮框
    var oGoTop = $(".js_goTop");
    // 回到顶部
    var oGlobalType = $(".js_globalType");
    // 结算的商品既有cc2.0的还有普通商品就要显示的弹窗
    var oGoodsSplitSum = $(".js_goodsSplitSum");
    // 选择按钮区域
    var oOverSeaNo = $(".js_overSeaNo");
    // 海外直邮商品个数
    var oOverSeaPrice = $(".js_overSeaPrice");
    // 海外直邮商品总价
    var oHomeNo = $(".js_homeNo");
    // 国内商品个数
    var oHomePrice = $(".js_homePrice");
    // 国内商品总计
    var oGoodsSplitReturn = $(".js_goodsSplitReturn");
    // 弹窗的返回按钮
    var oGoodsSplitNext = $(".js_goodsSplitNext");
    // 弹窗的结算按钮
    var nCcGoodsIdCount = "";
    // cc2.0商品id集合
    var nComGoodsIdCount = "";
    // 普通商品的id集合
    var oContainScroll = new myPub.ScrollBar();
    // 导航滚动条
    var oSideslipEven = new myPub.HammerEvent();
    var lazLoading = new myPub.lazLoadingImg();
    var oGoods_showTwo = $(".js_goods_showTwo ");
    var oSegmentation = $(".js_segmentation");
    // 猜你喜欢标题
    var oLikeGoods = $(".js_likeGoods");
    // 猜你喜欢区域
    var oNoMoregBtn = $(".js_noMoregBtn");
    // 没有更多了按钮
    var oLoadingBtn = $(".js_loadingBtn");
    // 加载中按钮
    var oGoodsList = $(".js_addGoods");
    // 商品列表
    // var guessLikeUrl = '/shop/goods/guessLike';         // 猜你喜欢商品列表地址
    var guessLikeUrl = "/m/g/1.0/group/listGoodsByName";
    //猜你喜欢 最新 商品列表地址
    var storeDetailUrl = "/m/g/supplier/1.0/isOverSeaSupplier";
    // 判斷是否海外商家
    var resizeTimer = null;
    // 获取产品数据的路径
    var goodsDateUrl = "/shop/cartItem/getCartItems";
    var oHeaderHeight = 0;
    var oPullDownHeight = 48;
    if (oHeader.length > 0) {
        oPullDownHeight = oHeaderHeight = oHeader.outerHeight(true);
    }
    // 回到过顶部
    oGoTop.hammer().on("tap", function() {
        oContainScroll.ScrollTo(0, 0, 250, function() {
            oSideBox.stop().animate({
                right: "-3.5rem"
            }, 300);
        });
        myPub.HamstopPropaga();
    });
    // 税费是0就不显示税费区域
    function toggleTax() {
        var ntaxPrice = oTaxSum.text() * 1;
        if (ntaxPrice == 0) {
            oTaxAll.hide();
        } else {
            oTaxAll.show();
        }
    }
    oTaxDelCar.each(function(index, el) {
        var ntaxrate = $(el).attr("taxrate") * 1;
        var nquality = $(el).attr("quality") * 1;
        $(el).html((ntaxrate * nquality).toFixed(2));
        toggleTax();
    });
    module.exports = {
        init: function(data, names) {
            var addImgTime = null;
            shopCar.init(true);
            shopCar.initEvent();
            shopCar.ScrollPage();
            shopCar.goToStoreEvent();
            addMore.addAjax(addMore.start, addMore.limit, true, function() {
                clearTimeout(addImgTime);
                addImgTime = setTimeout(function() {
                    shopCar.scrollInit();
                }, 250);
            });
            // 页面尺寸修改
            oWindow.on("resize", function() {
                if (resizeTimer) {
                    clearTimeout(resizeTimer);
                }
                resizeTimer = setTimeout(function() {
                    shopCar.init(true);
                }, 400);
            });
        }
    };
    var shopCar = {
        // 初始化
        init: function(off) {
            var _this = this;
            if (off) {
                oContain.css({
                    "padding-top": 0,
                    "padding-bottom": 0,
                    top: oHeaderHeight,
                    bottom: oFooter.outerHeight(true)
                });
                myPub.SetImgHeight(oGoods_showTwo);
            }
            _this.checkShopCarNum();
            lazLoading.AddLazLoadingImg(oScrollPage[0]);
            shopCar.scrollInit();
        },
        // 初始化事件
        initEvent: function() {
            var _this = this;
            var oCheckBox = $(".js_checkBox");
            // 单选按钮
            var oGrayBox = $(".js_grayBox");
            // 已下架按钮
            var oStoreOwner = $(".js_storeOwner");
            // 店家名称
            var oDelBtn = $(".js_btnDel");
            // 单个删除按钮
            shopCar.checkAllSelet();
            // 单选选中和取消
            oCheckBox.hammer().off("tap");
            oCheckBox.hammer().on("tap", function() {
                var $this = $(this);
                _this.seletedOne($this);
                myPub.HamstopPropaga();
            });
            // 店家全选 店名
            oStoreOwner.hammer().off("tap");
            oStoreOwner.hammer().on("tap", function() {
                var $this = $(this);
                _this.seletedAllStore($this);
                myPub.HamstopPropaga();
            });
            // 全选
            oAllseletBtn.hammer().off("tap");
            oAllseletBtn.hammer().on("tap", function() {
                _this.seletedAll();
                myPub.HamstopPropaga();
            });
            // 编辑 act_showSeletSize
            oStoreEditBtn.hammer().off("tap");
            oStoreEditBtn.hammer().on("tap", function() {
                var $this = $(this);
                var oGaryBox = $(".js_grayBox");
                // 下架商品
                var oGrayLi = oGaryBox.parents("li");
                // 下架商品的li;
                if ($this.hasClass("on")) {
                    var oCurrentGaryBox = $(".js_currentGaryBox");
                    $this.removeClass("on").text("编辑");
                    oShopCarGoods.find("li").removeClass("act_showSeletSize");
                    oBtnConfirm.show();
                    oBtnAllDel.hide();
                    oGoods_showTwo.show();
                    // 编辑完成把下架商品的置灰加上
                    oCurrentGaryBox.removeClass("js_checkBox");
                    oCurrentGaryBox.removeClass("js_currentGaryBox");
                    oCurrentGaryBox.addClass("gray");
                    oCurrentGaryBox.addClass("js_grayBox");
                    _this.initEvent();
                } else {
                    $this.addClass("on").text("完成");
                    oShopCarGoods.find("li").addClass("act_showSeletSize");
                    oBtnConfirm.hide();
                    oBtnAllDel.show();
                    oGoods_showTwo.hide();
                    oContainScroll.ScrollTo(0, 0, 250);
                    // 把下架商品的置灰去掉
                    oGrayLi.removeClass("act_showSeletSize");
                    oGaryBox.removeClass("gray");
                    oGaryBox.removeClass("js_grayBox");
                    oGaryBox.addClass("js_checkBox");
                    oGaryBox.addClass("js_currentGaryBox");
                    _this.initEvent();
                }
                oContainScroll.ReScroll();
                myPub.HamstopPropaga();
            });
            // 单个删除
            oDelBtn.hammer().off("tap");
            oDelBtn.hammer().on("tap", function() {
                var $this = $(this);
                _this.deleteOne($this);
                myPub.HamstopPropaga();
            });
            // 全部删除
            oBtnAllDel.hammer().off("tap");
            oBtnAllDel.hammer().on("tap", function() {
                var $this = $(this);
                _this.deleteAll($this, function() {
                    oBtnConfirm.show();
                    oBtnAllDel.hide();
                    oStoreEditBtn.removeClass("on").text("编辑");
                    oGoods_showTwo.show();
                    shopCar.checkAllSelet();
                });
                myPub.HamstopPropaga();
            });
        },
        // 检测是否空的购物车
        checkShopCarNum: function() {
            var _this = this;
            var oCheckBox = $(".js_checkBox");
            var oCarListHead = $(".js_carListHead");
            //店家
            var oCarList = $(".js_carList");
            //全部宝贝
            var oGrayBox = $(".js_grayBox");
            // 下架商品
            oCheckBox.removeClass("active");
            if (oShopCarGoods.find("li").length < 1) {
                oEmptyCar.show();
                oShopCarGoods.hide();
            } else {
                oEmptyCar.hide();
                var index = null;
                // 有正常商品的商家的下标
                // console.log('bbb',oCarList);
                // 全部是已下架商品的商家选中置灰
                oCarList.each(function(index, el) {
                    // console.log('aaaa'+index, el);
                    var _grayBoxNum = $(el).find(".js_grayBox").length;
                    var _liNum = $(el).find("li").length;
                    var oStoreOwner = oCarListHead.eq(index).find(".js_storeOwner");
                    // 商家全选
                    // console.log(index, oStoreOwner);
                    if (_grayBoxNum == _liNum) {
                        oStoreOwner.find(".js_checkBox").addClass("gray");
                        oStoreOwner.find(".js_checkBox").addClass("js_grayBox");
                        oStoreOwner.find(".js_checkBox").removeClass("js_checkBox");
                    }
                });
                // 全选按钮是否置灰
                _this.selectAllGray();
                // 找到第一个有正常商品的商家
                for (var i = 0; i < oCarList.length; i++) {
                    if (oCarList.eq(i).find(".js_checkBox").length > 0) {
                        index = i;
                        break;
                    }
                }
                // console.log('ccc',index);
                if (index != null) {
                    //默认第一个产品选中
                    if (oCarList.eq(index).find(".js_checkBox").length === 1) {
                        oCarListHead.eq(index).find(".js_checkBox").addClass("active");
                    }
                    oCarList.eq(index).find(".js_checkBox").eq(0).addClass("active");
                    oBtnAllDel.addClass("active");
                }
                /*if (oCarList.eq(0).find('.js_checkBox').length === 1) {
                    oCarListHead.eq(0).find('.js_checkBox').addClass('active');
                }
                oCarList.eq(0).find('.js_checkBox').eq(0).addClass('active');*/
                _this.checkPrice();
            }
        },
        // 全选按钮是否置灰
        selectAllGray: function() {
            var _this = this;
            var oCheckBox = $(".js_checkBox");
            var oGrayBox = $(".js_grayBox");
            // 下架商品
            if (oGrayBox && oCheckBox.length <= 0 && oGrayBox.length > 0) {
                oAllCheck.addClass("gray");
                oBtnAllDel.addClass("active");
                return;
            } else {
                oAllCheck.removeClass("gray");
            }
        },
        // 初始化 滚动 和 侧滑
        scrollInit: function() {
            //添加滚动
            if (oContainScroll.obj === undefined) {
                oContainScroll.AddScroll(oContain[0], {
                    id: "wrapScroll"
                });
                //添加下拉
                shopCarAjax.pullDown();
            } else {
                oContainScroll.ReScroll();
            }
            //添加侧滑
            shopCar.sideslip();
        },
        // 检测是否全选
        checkAllSelet: function() {
            var oCarListHead = $(".js_carListHead");
            //店家
            var _actNum = oCarListHead.find(".js_checkBox.active").length;
            var _checkNum = oCarListHead.find(".js_checkBox").length;
            // 商家选中个数为零
            if (_actNum === 0) {
                oAllCheck.removeClass("active");
                return;
            }
            //判断全部产品是否选中
            if (_actNum >= _checkNum) {
                oAllCheck.addClass("active");
            } else {
                oAllCheck.removeClass("active");
            }
        },
        // 检测是价格
        checkPrice: function() {
            var oCarList = $(".js_carList");
            //重新计算一下商品总数
            var orderNum = oCarList.find(".js_checkBox.active").length;
            nOrderNum.text(orderNum);
            // 重置合计税收价格
            myPub.ShopSumPrice(oCarList.find(".js_checkBox"), ".js_carListArea", ".js_taxDelCar", oTaxSum);
            //重置合计价格数据
            myPub.ShopSumPrice(oCarList.find(".js_checkBox"), ".js_carListArea", ".js_goodsPrice", oSumPrice);
            toggleTax();
        },
        // 单选
        seletedOne: function(obj) {
            var _this = this;
            var _parents = obj.parents(".js_carList");
            if (obj.hasClass("active")) {
                obj.removeClass("active");
                _parents.siblings(".js_carListHead").find(".js_checkBox").removeClass("active");
                oAllCheck.removeClass("active");
                if (oShopCarGoods.find(".js_checkBox.active").length < 1) {
                    oBtnAllDel.removeClass("active");
                }
            } else {
                obj.addClass("active");
                // 店家全选判断
                var _ActiveNum = _parents.find(".js_checkBox.active").length;
                var _CheckBoxNum = _parents.find(".js_checkBox").length;
                //判断当前店家产品是否选中
                if (_ActiveNum >= _CheckBoxNum) {
                    _parents.siblings(".js_carListHead").find(".js_checkBox").addClass("active");
                    _this.checkAllSelet();
                }
                oBtnAllDel.addClass("active");
            }
            _this.checkPrice();
        },
        // 全选
        seletedAll: function() {
            var _this = this;
            var oCheckBox = $(".js_checkBox");
            //单选按钮
            var oGrayBox = $(".js_grayBox");
            // 下架商品
            // 购物车无正常商品
            if (oCheckBox.length <= 0) {
                if (oGrayBox && oGrayBox.length > 0) {
                    // myPub.TipLayer('您所选的商品已下架');
                    oBtnAllDel.addClass("active");
                    return;
                } else {
                    myPub.TipLayer("您的购物车是空的哦！");
                    oAllCheck.removeClass("active");
                    oBtnAllDel.removeClass("active");
                    oSumPrice.text("0.00");
                    return;
                }
            } else {
                // 购物车有正常商品
                if (oAllCheck.hasClass("active")) {
                    oAllCheck.removeClass("active");
                    oCheckBox.removeClass("active");
                    oBtnAllDel.removeClass("active");
                    oSumPrice.text("0.00");
                } else {
                    oAllCheck.addClass("active");
                    oCheckBox.addClass("active");
                    oBtnAllDel.addClass("active");
                    _this.checkPrice();
                }
            }
        },
        // 商家全选
        seletedAllStore: function(obj) {
            var _this = this;
            var _checBox = obj.find(".js_checkBox");
            var _parents = obj.parents(".js_carListHead");
            if (_checBox.hasClass("active")) {
                _checBox.removeClass("active");
                _parents.siblings(".js_carList").find(".js_checkBox").removeClass("active");
                oAllCheck.removeClass("active");
                if (oShopCarGoods.find(".js_checkBox.active").length < 1) {
                    oBtnAllDel.removeClass("active");
                }
            } else {
                _checBox.addClass("active");
                _parents.siblings(".js_carList").find(".js_checkBox").addClass("active");
                oBtnAllDel.addClass("active");
                _this.checkAllSelet();
            }
            _this.checkPrice();
        },
        // 删除单个
        deleteOne: function(obj) {
            var _this = this;
            var _cont = '<p class="delTipP">确定删除该商品?</p><span class="delTipSpan">删除后不可恢复哦</span>';
            var $this = obj;
            myPub.askLayer(_cont, function() {
                var cartId = $this.parents("li").attr("cartItemId");
                G_JSON_POST("/shop/cartItem/removeCart/" + cartId, null, function(data) {
                    if (data.status == "success") {
                        var _carList = $this.parents(".js_carList");
                        var oStoreOwner = _carList.siblings(".js_carListHead").find(".js_storeOwner");
                        //判断是否只有1个产品
                        if ($this.parents(".js_shopCarGoods").find("li").length == 1) {
                            $this.parents(".js_carListBox").remove();
                            oEmptyCar.show();
                            oShopCarGoods.hide();
                            oGoods_showTwo.show();
                        } else if (_carList.find("li").length == 1) {
                            $this.parents(".js_carListBox").remove();
                        } else {
                            var _carListHeadCheck = _carList.siblings(".js_carListHead").find(".js_checkBox");
                            $this.parents("li").remove();
                            //删除后是否店家全选
                            _carList.find("li").length == _carList.find(".js_checkBox.active").length ? _carListHeadCheck.addClass("active") : _carListHeadCheck.removeClass("active");
                            // 删除后判断是否全部已下架商品
                            if (_carList.find(".js_grayBox") && _carList.find("li").length == _carList.find(".js_grayBox").length) {
                                oStoreOwner.find(".js_checkBox").addClass("gray");
                                oStoreOwner.find(".js_checkBox").addClass("js_grayBox");
                                oStoreOwner.find(".js_checkBox").removeClass("js_checkBox");
                            }
                        }
                        //判断是否高亮选中删除按钮
                        if (oShopCarGoods.find(".js_checkBox.active").length < 1) {
                            oBtnAllDel.removeClass("active");
                        } else {
                            oBtnAllDel.addClass("active");
                        }
                        // 全选按钮是否置灰
                        _this.selectAllGray();
                        _this.checkAllSelet();
                        _this.checkPrice();
                        _this.scrollInit();
                        myPub.LayerCloseAll();
                        myPub.TipLayer("删除成功！");
                    } else {
                        myPub.TipLayer(data.message);
                    }
                });
            }, function() {});
        },
        // 删除全部
        deleteAll: function(obj, fn) {
            var _this = this;
            var _cont = '<p class="delTipP">确定删除该商品?</p><span class="delTipSpan">删除后不可恢复哦</span>';
            var $this = obj;
            var cartIds = [];
            if ($this.hasClass("active")) {
                //可点击
                myPub.askLayer(_cont, function() {
                    var oCarListBox = oShopCarGoods.find(".js_carListBox");
                    if (oCarListBox.find(".js_checkBox.active").length == 0) {
                        myPub.LayerCloseAll();
                        myPub.TipLayer("您的购物车是空的哦！");
                        return;
                    }
                    oCarListBox.find(".js_checkBox.active").each(function(index, obj) {
                        if ($(this).hasClass("VBox")) {
                            cartIds.push(parseInt($(this).parents("li").attr("cartItemId")));
                        }
                    });
                    // console.log(cartIds);
                    G_JSON_POST("/shop/cartItem/removeCarts", {
                        cartIds: cartIds
                    }, function(data) {
                        if (data.status = "success") {
                            oShopCarGoods.find(".js_checkBox.active").parents("li").remove();
                            oCarListBox.each(function(i) {
                                if (oCarListBox.eq(i).find(".js_carList .js_checkBox").length < 1) {
                                    oCarListBox.eq(i).remove();
                                    oSumPrice.text(0);
                                    nOrderNum.text(0);
                                }
                            });
                            if ($(".js_carListBox").length == 0) {
                                oEmptyCar.show();
                                oShopCarGoods.hide();
                                if (fn) fn();
                            }
                            $this.removeClass("active");
                            _this.checkAllSelet();
                            _this.checkPrice();
                            _this.scrollInit();
                            myPub.LayerCloseAll();
                            myPub.TipLayer("删除成功！");
                        }
                    });
                }, function() {}, "no");
            } else {
                //不可点击
                myPub.TipLayer("没有选中要删除的宝贝！");
            }
        },
        // 侧滑
        sideslip: function() {
            oShopCarGoods.find("li").each(function(i) {
                oSideslipEven.addHamEvent(oShopCarGoods.find("li")[i], "panleft", function() {
                    oShopCarGoods.find("li").removeClass("act_showDel").eq(i).addClass("act_showDel");
                    myPub.HamstopPropaga();
                });
                oSideslipEven.addHamEvent(oShopCarGoods.find("li")[i], "panright", function() {
                    oShopCarGoods.find("li").removeClass("act_showDel");
                    myPub.HamstopPropaga();
                });
            });
        },
        // 滚动页面
        ScrollPage: function() {
            var _this = this;
            var scrollTime = null;
            var addLoadingTime = null;
            var minScrHeight = 200;
            oContainScroll.ScrollIng(function() {
                var _scrollTop = -oContainScroll.obj.y;
                var _scrollHeight = oContainScroll.obj.scrollerHeight;
                var _scrollPageHeight = oContainScroll.obj.wrapperHeight;
                clearTimeout(scrollTime);
                scrollTime = setTimeout(function() {
                    _this.ShowGoTop(_scrollTop);
                    // 统计曝光数据
                    // ddjAction.viewGoods( oGoodsList );
                    if (_scrollHeight - _scrollTop - _scrollPageHeight < minScrHeight) {
                        // 滚动加载产品
                        // 设置翻页到最后一页 返回
                        if (!addMore.bLoadOff) {
                            addMore.dataJson = null;
                            return;
                        }
                        // 滚动底部页数增加 起始数据等于上次结束数据  新的结束等于页数*页码数
                        addMore.start = addMore.limit * addMore.pagearr;
                        addMore.pagearr++;
                        addMore.addAjax(addMore.start, addMore.limit, false, function() {
                            clearTimeout(addLoadingTime);
                            addLoadingTime = setTimeout(function() {
                                shopCar.scrollInit();
                            }, 250);
                        });
                    }
                }, 800);
            });
        },
        // 显示回到顶部按钮
        ShowGoTop: function(scrollTop) {
            scrollTop > 150 ? oSideBox.stop().animate({
                right: 0
            }, 300) : oSideBox.stop().animate({
                right: "-3.5rem"
            }, 300);
        },
        // 点击进入店铺详情页面要判断是否是海外店铺
        goToStoreEvent: function() {
            var _this = this;
            $(".js_goToStore").on("click", function() {
                var supplierId = $(this).attr("data-supplierId");
                _this.goToStoreDetail(supplierId);
            });
        },
        // 判断是进入海外店铺还是进入普通店铺的接口
        goToStoreDetail: function(supplierId) {
            var _this = this;
            G_JSON_POST(storeDetailUrl, {
                supplierId: supplierId
            }, function(data) {
                var _data = data.data;
                var _ret = data.ret;
                // console.log('data',_data,_ret);
                if (_ret.code == "0") {
                    if (_data) {
                        // 海外馆商家
                        window.location.href = BASE_URL + "/h/store/storehome?supplierId=" + supplierId;
                    } else {
                        // 普通商家
                        window.location.href = BASE_URL + "/h/store/normalStore/" + supplierId;
                    }
                } else {
                    // 如果请求不到就跳转普通商家
                    window.location.href = BASE_URL + "/h/store/normalStore/" + supplierId;
                }
            });
        }
    };
    var addMore = {
        limit: 20,
        // 每次加载数据数目
        getData: [],
        // 获取接口返回的数据
        pagearr: 1,
        // 当前页码数
        start: 0,
        // 开始数据
        bLoadOff: true,
        // 加载开关
        loadNo: 0,
        // 加载次数
        // 获取数据
        addAjax: function(start, limit, bAddLoad, fn) {
            var _this = this;
            var sendNo = "";
            if (bAddLoad) {
                sendNo = {
                    start: start,
                    limit: limit,
                    isFirst: 1,
                    groupName: "H5_猜你喜欢"
                };
            } else {
                sendNo = {
                    start: start,
                    limit: limit,
                    groupName: "H5_猜你喜欢"
                };
            }
            if (_this.loadNo < 5) {
                G_JSON_GET(guessLikeUrl, sendNo, function(data) {
                    var _ret = data.ret;
                    if (_ret.code != "0") return;
                    _this.loadNo++;
                    _this.getData = data.data;
                    // 没有数据
                    if (_this.getData.length < 0 && _this.pagearr < 2) {
                        oNoMoregBtn.show();
                        oLoadingBtn.hide();
                        _this.bLoadOff = false;
                        oSegmentation.hide();
                        oLikeGoods.hide();
                        shopCar.scrollInit();
                        return;
                    }
                    if (_this.pagearr >= 1) {
                        if (_this.getData.length == 0) {
                            oNoMoregBtn.show();
                            oLoadingBtn.hide();
                            _this.bLoadOff = false;
                            shopCar.scrollInit();
                            return;
                        }
                    }
                    // 拼接页面
                    shopCarAjax.addHtml(_this.getData);
                    if (_this.getData.length < _this.limit) {
                        oNoMoregBtn.show();
                        oLoadingBtn.hide();
                        _this.bLoadOff = false;
                    }
                    data = null;
                    if (fn) fn();
                }, function() {}, function() {});
            } else {
                oNoMoregBtn.show();
                oLoadingBtn.hide();
                _this.bLoadOff = false;
                shopCar.scrollInit();
            }
        }
    };
    var shopCarAjax = {
        // 下拉刷新
        pullDown: function() {
            var _this = this;
            var _textTip = [ '<i class="textPull">轻轻下拉刷新，查看新加产品</i>', '<i class="textRelease HBox BoxCenter">' + '   <figure class="ddjLogoImg"><img src="' + BASE_URL + '/static_v4/image/iconPic/tip_ddj.png" alt=""></figure>' + '   <em class="ddjText">' + '       <span class="ddjText_tip">有担当， 更爱家 </span>' + "       <span>松手更新...</span>" + "   </em>" + "</i>", '<i class="textLoading HBox BoxCenter">' + '   <figure class="ddjLogoImg"><img src="' + BASE_URL + '/static_v4/image/iconPic/tip_ddj.png" alt=""></figure>' + '   <em class="ddjText">' + '       <span class="ddjText_tip">有担当， 更爱家 </span>' + "       <span>更新中...</span>" + "   </em>" + "</i>" ];
            //添加下拉
            oContainScroll.ScrollPullDown({
                pulldownHeight: oPullDownHeight,
                iconArrow: "",
                iconLoading: "",
                iconFinish: "",
                textPull: _textTip[0],
                textRelease: _textTip[1],
                textLoading: _textTip[2],
                textFinish: _textTip[2],
                spinning: false,
                refresh: function(complete) {
                    _this.ShopListAjaxData(function() {
                        lazLoading.DestroyLazLoadingImg();
                        lazLoading.AddLazLoadingImg(oScrollPage[0]);
                        SumEvent.SumPriceEvent();
                        GoodsSizeEvent.GoodsSizeSelet();
                        shopCar.checkAllSelet();
                        complete();
                    });
                }
            });
        },
        // 设置 购物车产品数据
        ShopListAjaxData: function(fn) {
            var html = "";
            G_JSON_POST(goodsDateUrl, {}, function(data) {
                // console.log(data.goodsNew.length);
                var dataJson = data.obj;
                if (data.status == "success") {
                    for (var p in dataJson) {
                        var sHtml = '<section class="carListBox js_carListBox">' + shopCarAjax.ShopStoreHtml(dataJson[p]) + shopCarAjax.ShopListHtml(dataJson[p].productList) + "</section>";
                        html += sHtml;
                    }
                    var $html = $(html);
                    oShopCarGoods.empty().prepend($html);
                    // 判断进入哪个店铺页面
                    shopCar.goToStoreEvent();
                    oEmptyCar.hide();
                    oShopCarGoods.show();
                    data = null;
                    dataJson = null;
                } else {
                    oEmptyCar.show();
                    oShopCarGoods.hide();
                }
            }, function() {}, function() {
                // end
                shopCar.init(false);
                shopCar.initEvent();
                if (fn) fn();
            });
        },
        // 购物车产品信息
        ShopListHtml: function(productList) {
            var _this = this;
            var sHtmlBox = "";
            var sHtml = "";
            var taxShtml = "";
            var isShelvesHtml = "";
            // 是否是下架商品
            var priceHtml = "";
            // 价格显示区域
            var GoodTypesHtml = "";
            // cc2.0商品标识或BC商品标识
            // if()act_fixedSize act_moreSize
            for (var p in productList) {
                if (productList[p].calGlobalFee && productList[p].calGlobalFee != undefined && productList[p].calGlobalFee != "") {
                    var ntaxPrice = (productList[p].calGlobalFee * productList[p].quantity).toFixed(2) * 1;
                    taxShtml = ' <div class="shopCarTax js_taxDelAreaCar">' + "              <span>预估税费：￥</span>" + '              <span class="js_taxDelCar" taxrate="' + productList[p].calGlobalFee + '" quality="' + productList[p].quantity + '">' + ntaxPrice + "</span>" + "         </div>";
                } else {
                    taxShtml = "";
                }
                isShelvesHtml = "";
                priceHtml = "";
                // shelves: 0,已上架，1：已售罄，2：已下架
                if (productList[p].shelves == 1) {
                    isShelvesHtml = '<span class="goodsCartNull goodsSellOut"></span>' + '<div class="checkBoxArea js_grayBox VBox BoxCenter gray" cartItemId="' + productList[p].cartItemId + '" globalOrderType="' + productList[p].crossBorderPattern + '">';
                    priceHtml = '<i class="goodsPrice">￥</i>' + '<span class="goodsPrice js_goodsPrice" pprice="' + productList[p].salePrice + '">' + productList[p].totalPrice.toFixed(2) + "</span>";
                } else if (productList[p].shelves == 2) {
                    isShelvesHtml = '<span class="goodsCartNull goodsShelves"></span>' + '<div class="checkBoxArea js_grayBox VBox BoxCenter gray" cartItemId="' + productList[p].cartItemId + '" globalOrderType="' + productList[p].crossBorderPattern + '">';
                    priceHtml = '<span class="goodsPrice">暂无报价</span>';
                } else {
                    isShelvesHtml = '<div class="checkBoxArea js_checkBox VBox BoxCenter " cartItemId="' + productList[p].cartItemId + '" globalOrderType="' + productList[p].crossBorderPattern + '">';
                    priceHtml = '<i class="goodsPrice">￥</i>' + '<span class="goodsPrice js_goodsPrice" pprice="' + productList[p].salePrice + '">' + productList[p].totalPrice.toFixed(2) + "</span>";
                }
                // cc2.0商品标识
                GoodTypesHtml = "";
                if (productList[p].crossBorderPattern == 4) {
                    GoodTypesHtml = '<div class="HBox goodsSplitMark">' + '   <div class="goodsSplitMarkIcon">' + '       <img src="' + BASE_URL + '/static_v4/image/iconImg/icon_globalCart.png" alt="">' + "   </div>" + '   <div class="goodsSplitMarkTxt">个人海外直邮商品</div>' + "</div>";
                } else if (productList[p].crossBorderPattern == 3) {
                    GoodTypesHtml = '<div class="HBox goodsSplitMark personalBc">' + '   <div class="goodsSplitMarkIcon">' + '       <img src="' + BASE_URL + '/static_v4/image/iconImg/icon_globalBC.png" alt="">' + "   </div>" + '   <div class="goodsSplitMarkTxt">海外直邮商品</div>' + "</div>";
                }
                sHtml += '<li cartItemId="' + productList[p].cartItemId + '" productId = "' + productList[p].id + '">' + '   <div class="sideslipScroll">' + GoodTypesHtml + // '<div class="tipInfoBox HBox BoxCenter">'+
                // '<em>满减</em>'+
                // '<span class="Bflex1">购满2件，总价可打8.00折</span>'+
                // '<a href="" class="color_red">'+
                // '<i>去凑单</i>'+
                // '<i class="icon-chevron-right"></i>'+
                // '</a>'+
                // '</div>'+
                '       <section class="HBox BoxCenter carListArea js_carListArea">' + isShelvesHtml + // '           <div class="checkBoxArea js_checkBox VBox BoxCenter " cartItemId="' + productList[p].cartItemId + '">' +
                '               <span class="checkBox icon-check"></span>' + "           </div>" + '           <div class="HBox Bflex1" >' + "               <figure>" + '                   <a href="' + BASE_URL + "/h/goodspay/goodsView/" + productList[p].goodsSn + '"><img class="js_lazyImg" data-echo="' + HTTP_IMAGE_URL + "" + productList[p].goodsImageUrl + smallImgArg200 + '" src="' + BASE_URL + '/static_v4/image/loadImg.jpg"></a>' + '                   <i class="tip-city"></i>' + "               </figure>" + '               <aside class="priceArea VBox Bflex1">' + '                   <div class="outProvince VBox Bflex1">' + '                   <div class="Bflex1 priceArea_name">' + '                       <h4><a href="' + BASE_URL + "/h/goodspay/goodsView/" + productList[p].goodsSn + '">' + productList[p].goodsName + "</a></h4>" + '                       <p class="smallFont_tip goodsSize js_goodsSize act_moreSize">' + "                           <span>规格:已选择</span>" + '                           <span class="js_sizeShow">' + productList[p].spcName + "</span>" + '                           <span class="iconStyle icon-href-down"></span>' + "                       </p>" + "                   </div>" + '                   <div class="priceArea_price">' + '                       <p class="HBox priceAreaBox">' + priceHtml + "                       </p>" + "                   </div>" + '                       <div class="amountBox HBox js_amountBox BoxCenter ">' + '                           <div class="js_grayGoods cartGrayGoods" ></div>' + '                           <button class="numBtn js_handBtn active incart " cartItemId="' + productList[p].cartItemId + '" type="button">-</button>' + '                           <input class="sumNum js_sumNum" cartItemId="' + productList[p].cartItemId + '" type="number" name="" id="" value="' + productList[p].quantity + '"  />' + '                           <button class="numBtn js_handBtn incart" cartItemId="' + productList[p].cartItemId + '" type="button">+</button>' + "                       </div>" + "                   </div>" + taxShtml + "               </aside>" + "           </div>" + '           <div class="jsMinCount" style="display: none" minCount="' + productList[p].minCount + '"></div>' + "       </section>" + "   </div>" + '   <aside class="btnDel HBox BoxCenter js_btnDel">' + '       <p class="Bflex1">删除</p>' + "   </aside>" + "</li>";
            }
            sHtmlBox = '<section class="carList js_carList goods_showChangeBox js_goods_showOne ">' + '   <div class="goods_showChange"><ul class="goodsList">' + sHtml + "</ul></div>" + "</section>";
            return sHtmlBox;
        },
        // 购物车商家信息
        ShopStoreHtml: function(data) {
            // console.log(data);
            var _this = this;
            var sHtml = '<section class="carListHead HBox BoxCenter js_carListHead">' + '<div class="storeOwner js_storeOwner Bflex1 HBox BoxCenter">' + '<div class="checkBoxArea js_checkBox">' + '<span class="checkBox icon-check"></span>' + "</div>" + '<div class="storeName Bflex1">' + '<span class="iconStyle icon_store"></span><span>' + data.nickName + "</span>" + "</div>" + "</div>" + // '<a href="' + BASE_URL + '/h/store/normalStore/' + data.id + '" class="iconStyle icon-href-right"></a>' +
            '<a data-supplierId="' + data.id + '" class="iconStyle icon-href-right js_goToStore"></a>' + "</section>";
            return sHtml;
        },
        // 拼接数据
        addHtml: function(data) {
            var thtml = "";
            for (var i = 0; i < data.length; i++) {
                var dataItem = data[i];
                var quanpeiHtml = "";
                //如果有全赔图标则显示
                if (dataItem.firstGueeImagePath) {
                    quanpeiHtml = '<div class="quanpei"><img src="https://img.sfddj.com/miniappImg/public/goodsInfo/' + dataItem.firstGueeImagePath + '" alt="" /></div>';
                }
                thtml += "<li>" + '   <a class="BoxSelf" href="' + BASE_URL + "/h/goodspay/goodsView/" + dataItem.goodsSn + '" requestid="' + dataItem.requestId + '"  goodsid="' + dataItem.id + '">' + "       <figure>" + '           <img class="js_lazyImg" data-echo="' + HTTP_IMAGE_URL + dataItem.goodsDefaultImage + smallImgArg200 + '" src="' + BASE_URL + '/static_v4/image/loadImg.jpg">' + quanpeiHtml + "       </figure>" + '       <aside class="priceArea VBox Bflex1">' + '           <div class="Bflex1 priceArea_name">' + "               <h4>" + dataItem.goodsName + "</h4>" + '               <p class="smallFont_tip">' + dataItem.goodsTitle + "</p>" + "           </div>" + '           <div class="priceArea_price">' + '               <p class="HBox priceAreaBox">' + '                   <span class="goodsPrice">￥' + dataItem.salePrice + "</span>" + "               </p>" + "           </div>" + "       </aside>" + "   </a>" + '   <p class="addCar js_addCar" pid="' + dataItem.productId + '"><em class="icon-shopcar_small"></em></p>' + "</li>";
            }
            oGoodsList.append(thtml);
            lazLoading.AddLazLoadingImg(oScrollPage[0]);
        }
    };
    // 商品的类型 0 非进口; 1 cc; 2 国内保税仓; 3 bc; 4 cc2.0; 
    var goodsType = {
        event: function() {
            var _this = this;
            // 结算海外还是国内单选
            oGoodsSplitSum.on("click", function(e) {
                var oGoodsSplitChoose = $(this).find(".js_goodsSplitChoose");
                var oSlibGoodsSplitChoose = $(this).siblings(".js_goodsSplitSum").find(".js_goodsSplitChoose");
                if (!oGoodsSplitChoose.hasClass("active")) {
                    oGoodsSplitChoose.addClass("active");
                }
                if (oSlibGoodsSplitChoose.hasClass("active")) {
                    oSlibGoodsSplitChoose.removeClass("active");
                }
                e.stopPropagation();
                myPub.HamstopPropaga();
            });
            // 返回按钮 隐藏弹窗
            oGoodsSplitReturn.on("click", function(e) {
                oGlobalType.hide();
                e.stopPropagation();
                myPub.HamstopPropaga();
            });
            // 弹窗的结算按钮
            oGoodsSplitNext.on("click", function(e) {
                var oChooseBox = oGoodsSplitSum.find(".js_goodsSplitChoose.active");
                var goodsIdCount = "";
                // 海外直邮商品
                if (oChooseBox.hasClass("js_overSeaBox")) {
                    goodsIdCount = nCcGoodsIdCount;
                } else {
                    goodsIdCount = nComGoodsIdCount;
                }
                $("#cartIds").val(goodsIdCount);
                var action = "/shop/pay/cartItem_confirm?cartIds=" + $("#cartIds").val() + "&goodschannel=" + $("#goodschannel").val() + "&recRequestId=" + $("#recRequestId").val() + "&sceneType=" + $("#sceneType").val();
                $("#subForm").attr("action", action);
                $("#subForm").submit();
                e.stopPropagation();
                myPub.HamstopPropaga();
            });
        }
    };
    goodsType.event();
    // 结算
    oBtnConfirm.hammer().on("tap", function() {
        var ids = "";
        var bBcType = false;
        // bc清关商品
        var bCcType2 = false;
        // cc2.0的商品
        var bComType = false;
        // 非cc2.0 非bc的商品
        var nCcNo2 = 0;
        // cc2.0商品总个数
        var nCcPrice2 = 0;
        // cc2.0商品总价格
        var nComNo = 0;
        // 普通商品总个数
        var nComPrice = 0;
        // 普通商品总价位
        $(".js_carListArea").find(".js_checkBox.active").each(function() {
            var globalType = $(this).attr("globalOrderType");
            var goodsPrice = $(this).parents(".js_carListArea").find(".js_goodsPrice").text() * 1;
            ids += $(this).attr("cartItemId") + ",";
            if (globalType == 3) {
                bBcType = true;
            } else if (globalType == 4) {
                bCcType2 = true;
                nCcNo2 += 1;
                nCcPrice2 += goodsPrice;
                nCcGoodsIdCount += $(this).attr("cartItemId") + ",";
            } else {
                bComType = true;
                nComNo += 1;
                nComPrice += goodsPrice;
                nComGoodsIdCount += $(this).attr("cartItemId") + ",";
            }
        });
        if (ids == "") {
            myPub.TipLayer("请选择要结算的商品");
            return;
        }
        // bc海外直邮商品不能在购物车购买
        if (bBcType) {
            myPub.TipLayer("海外直邮商品，仅支持商详页直接购买！");
            return;
        }
        // 如果结算的商品既有cc2.0的 还有普通商品 就要显示弹窗
        if (bCcType2 && bComType) {
            oOverSeaNo.text(nCcNo2);
            oOverSeaPrice.text(nCcPrice2.toFixed(2));
            oHomeNo.text(nComNo);
            oHomePrice.text(nComPrice.toFixed(2));
            oGlobalType.show();
            return;
        }
        $("#cartIds").val(ids);
        var action = "/shop/pay/cartItem_confirm?cartIds=" + $("#cartIds").val() + "&goodschannel=" + $("#goodschannel").val() + "&recRequestId=" + $("#recRequestId").val() + "&sceneType=" + $("#sceneType").val();
        $("#subForm").attr("action", action);
        $("#subForm").submit();
    });
    // 用户行为
    var ddjAction = {
        viewData: [],
        viewGoods: function(obj, iNow) {
            // 首页和分类区分
            var ddjActionPositionId = {};
            ddjActionPositionId.positionId = 2;
            // 个人中心 猜你喜欢
            ddjActionPositionId.positionFirst = "购物车";
            ddjActionPositionId.positionSecond = "猜你喜欢";
            // 统计曝光数据
            visualArea.viewEl.showViewEls(obj, function(data, dataJson) {
                ddjhoc.setData(data, "rec_show", "add", function() {
                    console.log("ddjhoc.params.rec_show.shopCar", ddjhoc.params);
                    if (ddjhoc.params.length != 0) ddjhoc.sendData(ddjhoc.params);
                    console.log("ddjhoc.ddjParams.rec_show.shopCar", ddjhoc.ddjParams);
                    if (ddjhoc.ddjParams.length != 0) ddjhoc.sendDDJData(ddjhoc.ddjParams);
                }, dataJson, ddjActionPositionId);
            });
        }
    };
});
/**
 * 快捷加入购物车 ---- 商品推荐右下角快捷加入购物车
 */
define("static_v4/js/mod/addcar_quick", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    //添加购物车动画
    var oMoveIcon = $(".js_moveIcon");
    // 加入购物车动态标记
    var oFooter = $(".js_footer");
    // 底部
    var oShopCarTip = $(".js_userNum");
    // 数量记录
    var oGoodsAddQuick = $(".js_goodsAddQuick");
    var oSideBox = $(".js_sideBox");
    // 侧边栏
    var oLoadingPage = $(".js_loadingPage");
    // 加载框
    var oShopCar_tip = $(".js_shopCar_tip");
    // 收藏加入购物车提示
    var AddBtn, clearTime, time1, time2, addOneTime;
    var dbTapOff = true;
    oGoodsAddQuick.hammer().off("tap");
    oGoodsAddQuick.hammer().on("tap", function(e) {
        if (dbTapOff) {
            //阻止多次点击 true 可点击  
            var _tag = e.gesture.target;
            var $target;
            _tag.nodeName.toLowerCase() == "p" ? $target = $(_tag) : $target = $(_tag).parents("p");
            var _X = e.gesture.center.x;
            var _Y = e.gesture.center.y;
            var win_Width = $(window).width();
            var win_Height = $(window).height();
            var oFooterH = oFooter.height();
            var oJSAddCar = $target.parents("li").find(".js_addCar");
            var pid = oJSAddCar.attr("pId");
            var regionId = oJSAddCar.attr("regionId") == undefined ? "" : oJSAddCar.attr("regionId");
            var $requestid = oJSAddCar.attr("requestid");
            var requestid = "";
            var scenetype = "";
            if ($requestid && $requestid != "undefined" && $requestid != "null") {
                requestid = $requestid;
            }
            var goodschannel = oJSAddCar.attr("goodschannel") == undefined ? "" : oJSAddCar.attr("goodschannel");
            if (goodschannel == "datagrand" || goodschannel == "not_datagrand") {
                scenetype = "cate";
            }
            var quantity = 1;
            if ($target.parents("li").find(".js_sumNum").length != 0) {
                quantity = $target.parents("li").find(".js_sumNum").val();
            }
            if ($target.length > 0 && $target[0].className == "addCar js_addCar") {
                var imgSrc = $target.parents("li").find("figure img").attr("src");
                var sLeft = "";
                var sTop = "";
                oMoveIcon.find("img").attr("src", imgSrc);
                dbTapOff = false;
                //var aLi = $(this).find('.js_addCar');
                //判断是商家页面 改变动画 left和top
                if (window.location.pathname.search("h/store/normalStore") > 0) {
                    sLeft = oSideBox.position().left + oMoveIcon.width() / 2;
                    sTop = oSideBox.position().top + oMoveIcon.width() * 1.5;
                } else if (window.location.pathname.search("cartItem/showCart") > 0) {
                    oLoadingPage.show();
                } else {
                    sLeft = win_Width * .63 - oMoveIcon.width() / 2;
                    sTop = win_Height - oFooterH - oMoveIcon.height() - oMoveIcon.height() / 10;
                }
                G_JSON_POST("/shop/cartItem/addCart", {
                    pId: pid,
                    quantity: quantity,
                    regionId: regionId,
                    goodschannel: goodschannel
                }, function(data) {
                    if (data.status == "success") {
                        var totalQuantity = data.totalQuantity;
                        if ($(".js_rightActive").length > 0) {
                            $target.append('<i class="addCarAnimate js_addCarAnimate">+1</i>');
                            clearTimeout(addOneTime);
                            addOneTime = setTimeout(function() {
                                $(".js_addCarAnimate").remove();
                                dbTapOff = true;
                            }, 1200);
                        } else {
                            myPub.AddCarAnimate(_X, _Y, oMoveIcon, sLeft, sTop, oFooterH, function() {
                                // 修改购物车数量
                                oShopCarTip.show().html(totalQuantity).addClass("mybounceIn");
                                // oShopCarTip.show().addClass('mybounceIn');
                                clearTimeout(clearTime);
                                clearTime = setTimeout(function() {
                                    oShopCarTip.removeClass("mybounceIn");
                                    dbTapOff = true;
                                }, 1200);
                            });
                        }
                        if (window.location.pathname.search("cartItem/showCart") > 0 || window.location.pathname.search("myInfo/toMyInfo")) {
                            var tipText = '<span class="icon-check-cir icon_myLayer_red"></span><span class="icon_myLayer_normal">加入购物车成功！</span>';
                            var tipStyle = "background-color: rgba(0,0,0,.6); color: #FFFFFF; min-width: 25%;";
                            if (oShopCarTip.length > 0) {
                                myPub.AddCarAnimate(_X, _Y, oMoveIcon, sLeft, sTop, oFooterH, function() {
                                    // 修改购物车数量
                                    oShopCarTip.show().html(totalQuantity).addClass("mybounceIn");
                                    // oShopCarTip.show().addClass('mybounceIn');
                                    clearTimeout(clearTime);
                                    clearTime = setTimeout(function() {
                                        oShopCarTip.removeClass("mybounceIn");
                                        dbTapOff = true;
                                    }, 1200);
                                });
                            } else {
                                myPub.TipLayer(tipText, tipStyle, function() {
                                    oLoadingPage.hide();
                                });
                            }
                        }
                        // 收藏加入购物车提示
                        if (oShopCar_tip.length > 0) {
                            oShopCar_tip.fadeIn();
                        }
                        // 添加用户行为
                        var setActionData = {};
                        setActionData.pid = pid * 1;
                        setActionData.num = 1;
                        setActionData.requestid = requestid;
                        setActionData.scenetype = scenetype;
                    } else {
                        myPub.TipLayer(data.message);
                        oLoadingPage.hide();
                        clearTimeout(time1);
                        time1 = setTimeout(function() {
                            dbTapOff = true;
                        }, 1200);
                    }
                    myPub.HamstopPropaga();
                }, function() {}, function() {
                    //完成
                    clearTimeout(time2);
                    time2 = setTimeout(function() {
                        oShopCar_tip.fadeOut();
                        dbTapOff = true;
                    }, 1200);
                });
                myPub.HamstopPropaga();
                e.stopPropagation();
            }
        }
    });
    // 添加用户行为
    function userAction(obj, mode, keyword) {
        ddjhoc.setData(obj, mode, "add", function() {
            console.log("params." + mode, ddjhoc.params);
            ddjhoc.sendData(ddjhoc.params);
        }, keyword);
    }
});
/**
 *  增加或减少(输入) 选择的商品
 */
define("static_v4/js/mod/sum", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    SumPriceEvent();
    function SumPriceEvent() {
        var oAmountBox = $(".js_amountBox");
        //数量框
        var oGoodsPrice = $(".js_goodsPrice");
        //产品价格
        var oSumNum = $(".js_sumNum");
        //总数
        var oSumPrice = $(".js_sumPrice");
        //总价格
        var oGoodsSizeList = $(".js_goodsSizeList");
        //产品规格列表
        var oGoodsSizeSide = $(".js_goodsSizeSide");
        // 全部弹层
        var minCount = $(".jsMinCount");
        // 起购份数
        var kucun = $(".kucun").attr("value");
        // 库存份数
        var oChooseNumArea = $(".js_chooseNumArea");
        // 选择数量区域
        var oTaxDelArea = $(".js_taxDelArea");
        // 显示税费区域
        var oTaxSum = $(".js_taxSum");
        // 总的税费
        var oTaxAll = $(".js_taxAll");
        // 计算总的税费区域
        //最大限制和最小限制
        var maxNum = 99;
        var minNum = 1;
        var bodyScrollTime = null;
        //数量输入框
        oSumNum.focus(function() {});
        /* oSumNum.blur(function() {
            var psdScrollTap_timer = null;
            oGoodsSizeList.show();
            oGoodsSizeSide.css({'bottom': 0});
            clearTimeout(psdScrollTap_timer);
            psdScrollTap_timer = setTimeout(function () {
                window.scrollTo(0,document.documentElement.clientHeight);
            },100);
        });*/
        function toggleTax() {
            var ntaxPrice = oTaxSum.text() * 1;
            if (ntaxPrice == 0) {
                oTaxAll.hide();
            } else {
                oTaxAll.show();
            }
        }
        oAmountBox.each(function(i) {
            var oHandBtn = oAmountBox.eq(i).find(".js_handBtn");
            var oGoodsPriceTxt = oGoodsPrice.eq(i).text();
            var iNow = oSumNum.eq(i).val();
            var oGrayGoods = oAmountBox.eq(i).parents(".js_carListArea");
            // 下架商品
            var oTaxDel = $(".js_taxDel");
            // 显示税费数字
            var taxRate = 0;
            // 税费单价
            var taxPriceNum = 0;
            // 税费金额
            if (oGrayGoods.find(".js_grayBox").length > 0) {
                oAmountBox.eq(i).find(".js_grayGoods").show();
            }
            oHandBtn.hammer().off("tap");
            oHandBtn.hammer().on("tap", function(e) {
                var oshopCarTax = $(this).parents(".outProvince").siblings(".js_taxDelAreaCar").find(".js_taxDelCar");
                // 购物车页面
                var taxRateCar = 0;
                if (oshopCarTax && oshopCarTax.length > 0) {
                    taxRateCar = oshopCarTax.attr("taxrate") * 1;
                }
                // 税费
                if (oTaxDelArea && oTaxDelArea.length > 0) {
                    taxRate = $(this).parents(".js_chooseNumArea").siblings(".js_goodsSizeList").find("li.active").attr("taxfare");
                    if (taxRate && taxRate != undefined && taxRate != "") {
                        taxRate = taxRate * 1;
                    } else {
                        taxRate = 0;
                    }
                } else {
                    taxRate = 0;
                }
                // 库存
                if (oChooseNumArea && oChooseNumArea.length > 0) {
                    kucun = $(this).parents(".js_chooseNumArea").siblings(".js_goodsSmallImg").find(".kucun").text();
                }
                var nMaxNum = minCount.eq(i).attr("maxCount") * 1;
                // 限购最大数
                //oGoodsPrice.eq(i).html((oGoodsPriceTxt*iNow).toFixed(2));
                var minBuyCount = 1;
                if (minCount.eq(i).attr("minCount") != null && minCount.eq(i).attr("minCount") != undefined) {
                    minBuyCount = parseInt(minCount.eq(i).attr("minCount"));
                }
                // 如果有限购的最大值存在且不为0 且小于等于99
                if (nMaxNum && nMaxNum != 0 && nMaxNum <= maxNum) {
                    maxNum = nMaxNum;
                } else {
                    maxNum = 99;
                }
                // 单价
                var oneGoodsPrice = oGoodsPrice.eq(i).attr("pPrice");
                var oneJifen = oGoodsPrice.eq(i).attr("jifen");
                var index = oHandBtn.index(this);
                var _iNow = oSumNum.eq(i).val();
                oSumNum.blur();
                oHandBtn.removeClass("active");
                switch (index) {
                  //减少
                    case 0:
                    if (_iNow == minBuyCount * 1 + 1 || _iNow == minBuyCount) {
                        oHandBtn.eq(index).addClass("active");
                    }
                    if (_iNow <= minBuyCount) {
                        _iNow = minBuyCount;
                        myPub.TipLayer("不能再少了");
                    } else {
                        _iNow--;
                    }
                    break;

                  //增加
                    case 1:
                    if (_iNow == maxNum || _iNow == maxNum * 1 - 1 || _iNow == kucun * 1 - 1 || _iNow == kucun) {
                        oHandBtn.eq(index).addClass("active");
                    }
                    if (_iNow > maxNum - 1) {
                        _iNow = maxNum;
                        myPub.TipLayer("最多只能" + maxNum + "，不要太贪心哦");
                    } else {
                        _iNow++;
                    }
                    break;
                }
                if (kucun && kucun.length > 0) {
                    if (_iNow > kucun * 1) {
                        _iNow = kucun;
                        myPub.TipLayer("库存不足哦");
                    }
                }
                //检测已经在购物车
                if ($(this).hasClass("incart")) {
                    var cartId = $(this).attr("cartItemId");
                    updateCart(cartId, _iNow, function() {
                        iNow = _iNow;
                        // 税费金额
                        taxPriceNum = (iNow * taxRate).toFixed(2) * 1;
                        oTaxDel.text("￥" + taxPriceNum.toFixed(2));
                        oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2));
                        oSumNum.eq(i).val(iNow);
                        oshopCarTax.text((taxRateCar * iNow).toFixed(2));
                        // 总的税费
                        myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_taxDelCar", oTaxSum);
                        myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_goodsPrice", oSumPrice);
                        // 税费是0就不显示税费
                        toggleTax();
                    }, function() {
                        oSumNum.eq(i).val(iNow);
                    });
                } else {
                    iNow = _iNow;
                    //判断积分显示
                    var returnMoneyPercentage = $(".js_goodsPrice").attr("returnMoneyPercentage");
                    var oReturnMoney = $("#returnMoney");
                    var oCostMemberScore = $("#costMemberScore");
                    if (oneJifen != undefined) {
                        if (oneGoodsPrice * iNow == 0) {
                            oGoodsPrice.eq(i).html(oneJifen * iNow + "积分");
                        } else {
                            if (returnMoneyPercentage != undefined && returnMoneyPercentage != null && returnMoneyPercentage != 0 && oReturnMoney.length > 0) {
                                oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2) + "+" + oneJifen * iNow + "积分");
                                oReturnMoney.html((returnMoneyPercentage * iNow * oneGoodsPrice / 100).toFixed(2));
                            } else {
                                oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2) + "+" + oneJifen * iNow + "积分");
                            }
                        }
                    } else {
                        // 税费金额
                        taxPriceNum = (iNow * taxRate).toFixed(2) * 1;
                        oTaxDel.text("￥" + taxPriceNum.toFixed(2));
                        if (returnMoneyPercentage != undefined && returnMoneyPercentage != null && returnMoneyPercentage != 0 && oReturnMoney.length > 0) {
                            oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2));
                            oReturnMoney.html((returnMoneyPercentage * iNow * oneGoodsPrice / 100).toFixed(2));
                        } else {
                            oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2));
                        }
                        if (oCostMemberScore.length > 0) {
                            var memberCostScore = oCostMemberScore.attr("costMemberScore");
                            oCostMemberScore.html(memberCostScore * iNow);
                        }
                    }
                    oSumNum.eq(i).val(iNow);
                }
            });
            oSumNum.eq(i).off("input propertychange");
            oSumNum.eq(i).on("input propertychange", function(e) {
                var oshopCarTax = $(this).parents(".outProvince").siblings(".js_taxDelAreaCar").find(".js_taxDelCar");
                // 购物车页面
                var taxRateCar = 0;
                if (oshopCarTax && oshopCarTax.length > 0) {
                    taxRateCar = oshopCarTax.attr("taxrate") * 1;
                }
                // 税费
                if (oTaxDelArea && oTaxDelArea.length > 0) {
                    taxRate = $(this).parents(".js_chooseNumArea").siblings(".js_goodsSizeList").find("li.active").attr("taxfare");
                    if (taxRate && taxRate != undefined && taxRate != "") {
                        taxRate = taxRate * 1;
                    } else {
                        taxRate = 0;
                    }
                } else {
                    taxRate = 0;
                }
                // 库存
                if (oChooseNumArea && oChooseNumArea.length > 0) {
                    kucun = $(this).parents(".js_chooseNumArea").siblings(".js_goodsSmallImg").find(".kucun").text();
                }
                var sumThis = $(this);
                var reg = new RegExp("^[0-9]*$");
                // 验证数字
                // 单价
                var oneGoodsPrice = oGoodsPrice.eq(i).attr("pPrice");
                var oneJifen = oGoodsPrice.eq(i).attr("jifen");
                oHandBtn.removeClass("active");
                var nMaxNum = minCount.eq(i).attr("maxCount") * 1;
                // 限购最大数
                // 如果有限购的最大值存在且不为0 切小于等于99
                if (nMaxNum && nMaxNum != 0 && nMaxNum <= maxNum) {
                    maxNum = nMaxNum;
                } else {
                    maxNum = 99;
                }
                var minBuyCount = 1;
                if (minCount.eq(i).attr("minCount") != null && minCount.eq(i).attr("minCount") != undefined) {
                    minBuyCount = parseInt(minCount.eq(i).attr("minCount"));
                }
                if (!reg.test(oSumNum.eq(i).val())) {
                    myPub.TipLayer("输入正确数字");
                    oSumNum.eq(i).val(minBuyCount);
                    oHandBtn.eq(0).addClass("active");
                } else if (oSumNum.eq(i).val() <= 0) {
                    oSumNum.eq(i).val(minBuyCount);
                } else {
                    var _iNow = oSumNum.eq(i).prop("value") * 1;
                    // 设置最大值会导致底部上移
                    if (_iNow > maxNum - 1) {
                        _iNow = maxNum;
                        oSumNum.eq(i).val(_iNow);
                        myPub.TipLayer("最多只能" + maxNum + "，不要太贪心哦");
                        oHandBtn.eq(1).addClass("active");
                    }
                    if (_iNow < minBuyCount) {
                        _iNow = minBuyCount;
                        oSumNum.eq(i).val(_iNow);
                        oHandBtn.eq(0).addClass("active");
                        myPub.TipLayer("不能再少了");
                    }
                    if (kucun && kucun.length > 0) {
                        if (_iNow > kucun) {
                            _iNow = kucun;
                            oHandBtn.eq(1).addClass("active");
                            myPub.TipLayer("库存不足哦");
                        }
                    }
                    if (sumThis.hasClass("incart")) {
                        var cartId = oSumNum.eq(i).attr("cartItemId");
                        updateCart(cartId, _iNow, function() {
                            iNow = _iNow;
                            // 税费金额
                            taxPriceNum = (iNow * taxRate).toFixed(2) * 1;
                            oTaxDel.text("￥" + taxPriceNum.toFixed(2));
                            oGoodsPrice.eq(i).html((oneGoodsPrice * iNow).toFixed(2));
                            // 总的税费
                            myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_taxDelCar", oTaxSum);
                            myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_goodsPrice", oSumPrice);
                            // 税费是0就不显示税费
                            toggleTax();
                        }, function() {
                            oSumNum.eq(i).val(iNow);
                        });
                    } else {
                        oSumNum.eq(i).val(_iNow);
                    }
                }
                /* myPub.ValiNum(oSumNum.eq(i),function() {
                    myPub.TipLayer('输入正确数字');
                    oSumNum.eq(i).val(1);

                    oHandBtn.eq(0).addClass('active');
                },function() {
                    var _iNow = oSumNum.eq(i).prop('value')*1;
                    // 设置最大值会导致底部上移
                    if(_iNow > maxNum-1) {
                        _iNow = maxNum;
                        oSumNum.eq(i).val(_iNow);
                        myPub.TipLayer("最多只能"+maxNum+"，不要太贪心哦");

                        oHandBtn.eq(1).addClass('active');
                    }
                    if(_iNow < minBuyCount) {
                        _iNow = minBuyCount;
                        oSumNum.eq(i).val(_iNow);
                        oHandBtn.eq(0).addClass('active');
                        myPub.TipLayer("不能再少了");
                    }
                    if(_iNow > kucun){
                        _iNow = kucun;
                        oHandBtn.eq(1).addClass('active');
                        myPub.TipLayer("库存不足哦");
                    }
                    if(sumThis.hasClass('incart')){
                        var cartId = oSumNum.eq(i).attr("cartItemId");
                        updateCart(cartId,_iNow,function(){
                            iNow = _iNow;
                            oGoodsPrice.eq(i).html((oneGoodsPrice*iNow).toFixed(2));

                            myPub.ShopSumPrice($('.js_carList').find('.js_checkBox'),'.js_carListArea','.js_goodsPrice',oSumPrice);
                        },function(){
                            oSumNum.eq(i).val(iNow);
                        });
                    }else{

                        oSumNum.eq(i).val(_iNow);
                    }
                });*/
                $(".layermmain").css({
                    top: 25 + "%"
                });
                var returnMoneyPercentage = $(".js_goodsPrice").attr("returnMoneyPercentage");
                var oReturnMoney = $("#returnMoney");
                var oCostMemberScore = $("#costMemberScore");
                //判断积分显示
                if (oneJifen != undefined) {
                    if (oneGoodsPrice * oSumNum.eq(i).val() == 0) {
                        oGoodsPrice.eq(i).html(oneJifen * oSumNum.eq(i).val() + "积分");
                    } else {
                        if (returnMoneyPercentage != undefined && returnMoneyPercentage != null && returnMoneyPercentage != 0 && oReturnMoney.length > 0) {
                            oGoodsPrice.eq(i).html((oneGoodsPrice * oSumNum.eq(i).val()).toFixed(2) + "+" + oneJifen * oSumNum.eq(i).val() + "积分");
                            oReturnMoney.html((oneGoodsPrice * returnMoneyPercentage * oSumNum.eq(i).val() / 100).toFixed(2));
                        } else {
                            oGoodsPrice.eq(i).html((oneGoodsPrice * oSumNum.eq(i).val()).toFixed(2) + "+" + oneJifen * oSumNum.eq(i).val() + "积分");
                        }
                    }
                } else {
                    // 税费金额
                    taxPriceNum = (oSumNum.eq(i).val() * taxRate).toFixed(2) * 1;
                    oTaxDel.text("￥" + taxPriceNum.toFixed(2));
                    if (returnMoneyPercentage != undefined && returnMoneyPercentage != null && returnMoneyPercentage != 0 && oReturnMoney.length > 0) {
                        oGoodsPrice.eq(i).html((oneGoodsPrice * oSumNum.eq(i).val()).toFixed(2));
                        oReturnMoney.html((oneGoodsPrice * returnMoneyPercentage * oSumNum.eq(i).val() / 100).toFixed(2));
                    } else {
                        oGoodsPrice.eq(i).html((oneGoodsPrice * oSumNum.eq(i).val()).toFixed(2));
                        // 税费
                        oshopCarTax.html((taxRateCar * oSumNum.eq(i).val()).toFixed(2));
                        // 总的税费
                        myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_taxDelCar", oTaxSum);
                        myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_goodsPrice", oSumPrice);
                    }
                    if (oCostMemberScore.length > 0) {
                        var memberCostScore = oCostMemberScore.attr("costMemberScore");
                        oCostMemberScore.html(memberCostScore * oSumNum.eq(i).val());
                    }
                }
                // //详情价格动态改动
                // oGoodsPrice.eq(i).html((oneGoodsPrice * oSumNum.eq(i).val()).toFixed(2));
                e.preventDefault();
            });
        });
        /*
         oSumNum.on('focus',function() {
         $('.layermmain').css({'top':25+'%'})

         });
         oSumNum.on('blur',function() {
         $('.layermmain').css({'top':0})
         })
         */
        function updateCart(cartId, quantity, successfn, failfn) {
            G_JSON_POST("/shop/cartItem/updateCart", {
                cartId: cartId,
                quantity: quantity
            }, function(data) {
                if (data.status == "success") {
                    successfn();
                } else {
                    failfn();
                    myPub.TipLayer(data.message);
                }
            });
        }
        function setFocusScrollTop() {}
    }
    exports.SumPriceEvent = SumPriceEvent;
});
/**
 *  产品规格选择
 */
define("static_v4/js/mod/goodsSize_selet", [ "./public", "./sum" ], function(require, exports, module) {
    var myPub = require("./public");
    var SumEvent = require("./sum");
    var oTaxDelArea = $(".js_taxDelArea");
    // 显示税费区域
    var oTaxDel = $(".js_taxDel");
    // 显示税费数字
    var taxPriceNum = 0;
    // 税费金额
    var taxRate = 0;
    // 税费单价
    var oGoodsPrice = $("#salePrice");
    // 价格处
    var nPrice = 0;
    // 当前单价
    GoodsSizeSelet();
    function GoodsSizeSelet() {
        var oGoodsSizeSide = $(".js_goodsSizeSide");
        // 全部弹层
        var oMoreSizeSide = $(".js_moreSizeSide");
        // 多规格框
        var oFixedSizeSide = $(".js_fixedSizeSide");
        // 任选规格
        var oSumNum = $(".js_sumNum");
        //总数
        var oSeletNumBtn = $(".js_seletNumBtn");
        // 规格选择数量提示按钮
        var oOKBtn = $(".js_OKBtn");
        // 确定按钮
        var oCloseSideBtn = $(".js_closeSideBtn");
        // 关闭按钮
        var oShadow = $(".js_shadow");
        // 阴影
        var oShowIntro = $(".js_showIntro");
        // 送礼介绍
        var oSideScroll_moreSize = new myPub.ScrollBar();
        // 规格滚动条
        var oSideScroll_fixedSize = new myPub.ScrollBar();
        // 规格滚动条
        var giftOrder = "";
        //送他订单
        var layerStyle = "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px; min-width: 50%";
        if (oMoreSizeSide.length > 0) {
            oSideScroll_moreSize.AddScroll(oMoreSizeSide.find(".js_goodsSizeList")[0]);
        } else if (oFixedSizeSide.length > 0) {
            oSideScroll_fixedSize.AddScroll(oFixedSizeSide.find(".js_goodsSizeList")[0]);
        }
        var moveHeight = oGoodsSizeSide.outerHeight(true);
        // 弹框高度
        oGoodsSizeSide.css({
            bottom: -moveHeight
        });
        var oSellMemberId = $("#sellMemberId");
        // 丰享sellMemberId
        var buynowSuper = $("#buynow_super_id");
        var index_oGoodsSize = 0;
        oGoodsSizeSide.on("touchmove", function(e) {
            e.preventDefault();
        });
        // 关闭按钮关闭弹层
        oCloseSideBtn.hammer().on("tap", function() {
            $(".js_sumNum").blur();
            oGoodsSizeSide.stop().animate({
                bottom: -moveHeight
            }, 250, function() {
                oGoodsSizeSide.hide();
                oShadow.hide();
                oOKBtn.removeClass("act_joinCar act_payMust");
                if (typeof mui !== "undefined") {
                    myPub.OffMuiEvent(true);
                }
            });
            oShowIntro.hide();
            myPub.HamstopPropaga();
        });
        //阴影关闭
        oShadow.hammer().on("tap", function() {
            $(".js_sumNum").blur();
            oGoodsSizeSide.stop().animate({
                bottom: -moveHeight
            }, 250, function() {
                oGoodsSizeSide.hide();
                oShadow.hide();
                oOKBtn.removeClass("act_joinCar act_payMust");
                if (typeof mui !== "undefined") {
                    myPub.OffMuiEvent(true);
                }
            });
            oShowIntro.hide();
            myPub.HamstopPropaga();
        });
        var seletSize = {
            init: function() {
                var _this = this;
                _this.initEvent();
            },
            initEvent: function() {
                var _this = this;
                var oGoodsSize = $(".js_goodsSize");
                // 选择规格入口
                // var index_oGoodsSize = 0;
                oGoodsSize.hammer().off("tap");
                oGoodsSize.hammer().on("tap", function() {
                    var index = oGoodsSize.index($(this));
                    $(".js_sumNum").blur();
                    index_oGoodsSize = index;
                    // 购物车列表
                    if ($(this).parents("li").hasClass("act_showSeletSize")) {
                        var $this = $(this);
                        var cartId = $this.parents("li").attr("cartitemid");
                        var productId = $this.parents("li").attr("productId");
                        var price = $this.parents("li").find(".js_goodsPrice").text();
                        var sumNum = $this.parents("li").find(".js_sumNum").val();
                        _this.setLayerData($this, cartId, productId, price, sumNum, function(iavPathArrays, specProductDates, productDatas) {
                            _this.JudgeSizeSide($this, iavPathArrays, specProductDates, productDatas);
                        });
                        oOKBtn.removeClass("act_joinCar act_payMust");
                    } else {
                        if (typeof mui !== "undefined") {
                            myPub.OffMuiEvent(false);
                        }
                        // 加入购物车
                        if ($(this).hasClass("act_joinCar")) {
                            _this.JudgeSizeSide($(this));
                            oOKBtn.addClass("act_joinCar");
                        } else if ($(this).hasClass("act_payMust")) {
                            _this.JudgeSizeSide($(this));
                            oOKBtn.addClass("act_payMust");
                            //送他
                            if ($(this).hasClass("js_giftOrder")) {
                                giftOrder = 1;
                                // if(obj.hasClass('act_moreSize')) {
                                // oMoreSizeSide
                                oShowIntro.show();
                            } else {
                                giftOrder = 0;
                            }
                        }
                    }
                    myPub.HamstopPropaga();
                    return index_oGoodsSize;
                });
                // 确定按钮
                oOKBtn.hammer().off("tap");
                oOKBtn.hammer().on("tap", function() {
                    // var $this = $(this);
                    //当商品无货时  关闭按钮点击
                    if (tapFlag) {
                        return;
                    }
                    var $this = $(this);
                    if ($this.hasClass("act_payMust") || $this.hasClass("act_joinCar")) {
                        if (getLiParentHtml() == false) {
                            return;
                        }
                    }
                    var $parent = $this.parents(".js_goodsSizeSide");
                    var _price = $parent.find(".js_goodsSmallImg .js_goodsPrice").text();
                    var _size = $parent.find(".js_goodsSmallImg .js_user_seleted span").text();
                    var _num = $parent.find(".js_sumNum").val();
                    var _img = $("#currentImg").attr("src");
                    if (_num === undefined) _num = 1;
                    oGoodsSizeSide.stop().animate({
                        bottom: -moveHeight
                    }, 250, function() {
                        if ($this.hasClass("act_joinCar")) {
                            oOKBtn.removeClass("act_joinCar act_payMust");
                            // 加入购物车
                            var quantity = $("#quantity").val();
                            if (selectedProductId == "" || selectedProductId == undefined) {
                                selectedProductId = $("#selectedProductId").val();
                            }
                            G_JSON_POST("/shop/cartItem/addCart", {
                                pId: selectedProductId,
                                quantity: quantity,
                                goodschannel: goodschannel,
                                liveId: liveId,
                                regionId: regionId
                            }, function(data) {
                                if (data.status == "success") {
                                    var cartCount = data.cartCount;
                                    myPub.OffMuiEvent(true);
                                    myPub.TipLayer("加入购物车成功！", layerStyle);
                                    if (typeof setActionData != "undefined") {
                                        console.log(setActionData);
                                        // 添加用户行为
                                        // var setActionDatas = {};
                                        setActionData.pid = selectedProductId * 1;
                                        setActionData.num = quantity * 1;
                                    }
                                    $.ajax({
                                        type: "POST",
                                        url: "/shop/cartItem/getCount",
                                        dataType: "json",
                                        success: function(data) {
                                            if (data.count != 0) {
                                                $(".js_userNum").show();
                                                $(".js_userNum").html(data.count);
                                            } else {
                                                $(".js_userNum").hide();
                                            }
                                        },
                                        error: function(textStatus) {
                                            if (textStatus.status == 403) {
                                                $(".js_userNum").hide();
                                            }
                                        },
                                        complete: function(XHR) {
                                            XHR = null;
                                        }
                                    });
                                } else {
                                    myPub.TipLayer(data.message);
                                }
                            });
                            oGoodsSizeSide.hide();
                            oShadow.hide();
                        } else if ($this.hasClass("act_payMust")) {
                            var nchooseNum = $(".js_sumNum").val() * 1;
                            // 现在选中的数量
                            if (xgCount != 0 && xgCount < nchooseNum) {
                                myPub.TipLayer("超出限购数量" + xgCount + "件，无法立即购买");
                                oGoodsSizeSide.hide();
                                oShadow.hide();
                                return;
                            }
                            // 只针对顺丰速运商品，如限购10件 已购买了5件 这时的orderCount就是5
                            if (orderCount != 0 && orderCount < nchooseNum) {
                                myPub.TipLayer("您现在最多只能购买" + xgCount + "件哦~");
                                oGoodsSizeSide.hide();
                                oShadow.hide();
                                return;
                            }
                            myPub.OffMuiEvent(true);
                            oOKBtn.removeClass("act_joinCar act_payMust");
                            var productIds = [];
                            if ($this.hasClass("js_flowerMulti")) {
                                //任选商品点击的id    鲜花任选结算
                                $(".js_goodsSizemob").find("li.active").each(function(i) {
                                    var temval = $(".js_goodsSizemob").find("li.active").eq(i).attr("id");
                                    productIds.push(temval);
                                });
                                //工具的id
                                $(".js_otherSize").find("li.active").each(function(i) {
                                    var temval = $(".js_otherSize").find("li.active").eq(i).attr("id");
                                    productIds.push(temval);
                                });
                                // // 添加用户行为
                                // var setActionDatas = [];
                                // setActionDatas.pid = selectedProductId * 1;
                                // setActionDatas.num = quantity * 1;
                                // for(var i=0; i<productIds.length; i++) {
                                //     setActionDatas[i] = {};
                                //     setActionDatas[i].pid = productIds[i] * 1;
                                //     setActionDatas[i].num = 1;
                                // }
                                // userAction(productIds, 'buy', setActionDatas);
                                window.location.href = "/shop/pay/buynowMulti?productIds=" + productIds;
                                oGoodsSizeSide.hide();
                                oShadow.hide();
                            } else {
                                if (selectedProductId == "" || selectedProductId == undefined) {
                                    selectedProductId = $("#selectedProductId").val();
                                }
                                var groupCountParam = "";
                                if (typeof countStatus != "undefined" && typeof goodsGroupId != "undefined") {
                                    if (countStatus != "" && countStatus == "true" && goodsGroupId != "") {
                                        groupCountParam = "&countStatus=" + countStatus + "&goodsGroupId=" + goodsGroupId;
                                    }
                                }
                                //立即购买参数验证  及其购买操作  单规格  多规格 结算
                                var quantity = $("#quantity").val();
                                // // 添加用户行为
                                // var setActionDatas = {};
                                // setActionDatas.pid = selectedProductId * 1;
                                // setActionDatas.num = quantity * 1;
                                // userAction(oOKBtn, 'buy', setActionDatas);
                                if (giftOrder == 1) {
                                    //埋点
                                    try {
                                        var nowTime = new Date();
                                        nowTime = myPub.FormatDateTime(nowTime, null);
                                        console.log(nowTime);
                                        gio("track", "click_songta", {
                                            songtaclicktime: nowTime
                                        });
                                    } catch (e) {
                                        console.log("growIngIo 送他埋点上报数据异常");
                                    }
                                    // 送礼功能
                                    if (quantity > 1) {
                                        //如果数量大于1，那么挑起选择送礼方式弹层
                                        var oGiftSend_TypeSelet = $(".js_giftSend_TypeSelet");
                                        // 送礼方式弹层
                                        var oTypeSeletList = $(".js_typeSeletList");
                                        // 送礼方式选择
                                        var oTypeSeletIntro_layer = $(".js_typeSeletIntro_layer");
                                        // 送礼方式说明
                                        if (oSellMemberId.val() != undefined) {
                                            oTypeSeletList.find("a.oneGift").attr("href", "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&sellMemberId=" + oSellMemberId.val() + "&giftOrder=1&liveId=" + liveId + "&regionId=" + regionId);
                                            oTypeSeletList.find("a.multiGift").attr("href", "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&sellMemberId=" + oSellMemberId.val() + "&giftOrder=2&liveId=" + liveId + "&regionId=" + regionId);
                                        } else {
                                            oTypeSeletList.find("a.oneGift").attr("href", "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&goodschannel=" + goodschannel + "&recRequestId=" + recRequestId + "&sceneType=" + sceneType + "&giftOrder=1&liveId=" + liveId + "&regionId=" + regionId);
                                            oTypeSeletList.find("a.multiGift").attr("href", "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&goodschannel=" + goodschannel + "&recRequestId=" + recRequestId + "&sceneType=" + sceneType + "&giftOrder=2&liveId=" + liveId + "&regionId=" + regionId);
                                        }
                                        oGoodsSizeSide.hide();
                                        oShadow.hide();
                                        oShadow.show();
                                        oGiftSend_TypeSelet.show();
                                        oTypeSeletList.show();
                                        oTypeSeletIntro_layer.hide();
                                    } else {
                                        if (oSellMemberId.val() != undefined) {
                                            window.location.href = "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&sellMemberId=" + oSellMemberId.val() + "&giftOrder=" + giftOrder + "&liveId=" + liveId + "&regionId=" + regionId;
                                        } else {
                                            window.location.href = "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&goodschannel=" + goodschannel + "&recRequestId=" + recRequestId + "&sceneType=" + sceneType + "&giftOrder=" + giftOrder + "&liveId=" + liveId + "&regionId=" + regionId + groupCountParam + "&kcuid=" + kcuid;
                                        }
                                        oGoodsSizeSide.hide();
                                        oShadow.hide();
                                        oShowIntro.hide();
                                    }
                                } else {
                                    if (oSellMemberId.val() != undefined) {
                                        window.location.href = "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&sellMemberId=" + oSellMemberId.val() + "&giftOrder=" + giftOrder + "&liveId=" + liveId + "&regionId=" + regionId + groupCountParam;
                                    } else {
                                        if (buynowSuper.val() == 1) {
                                            window.location.href = "/super/buynow_super?productIdAndquantity=" + selectedProductId + "," + quantity;
                                        } else {
                                            // 针对顺丰速运商品 判断顺丰速运的纯积分产品 积分不足时弹窗提示
                                            if (sfMember && sfMember == "changwenSB" && productDatasGoodsDetail && productDatasGoodsDetail[selectedProductId].memberPrice && productDatasGoodsDetail[selectedProductId].memberPrice <= 0 && memberScore && memberScore >= 0) {
                                                var memberCoin = $this.parents(".js_moreSizeSide").find(".js_goodsSizemob").find("li.active").attr("costmemberscore") * 1;
                                                var costCoin = 0;
                                                var myCoin = memberScore * 1;
                                                if (memberCoin && memberCoin > 0) {
                                                    costCoin = memberCoin * quantity * 1;
                                                    if (costCoin > myCoin) {
                                                        myPub.TipLayer("您的积分不足，无法兑换！", "no");
                                                        oGoodsSizeSide.hide();
                                                        oShadow.hide();
                                                        return;
                                                    }
                                                }
                                            } else if (memberScore && memberScore == -1) {
                                                myPub.TipLayer("您的积分不足，无法兑换！", "no");
                                                oGoodsSizeSide.hide();
                                                oShadow.hide();
                                                return;
                                            }
                                            window.location.href = "/shop/pay/buynow?productIdAndquantity=" + selectedProductId + "," + quantity + "&goodschannel=" + goodschannel + "&recRequestId=" + recRequestId + "&sceneType=" + sceneType + "&giftOrder=" + giftOrder + "&liveId=" + liveId + "&regionId=" + regionId + groupCountParam + "&kcuid=" + kcuid;
                                        }
                                    }
                                    oGoodsSizeSide.hide();
                                    oShadow.hide();
                                }
                            }
                        } else {
                            var cartId = oGoodsSize.eq(index_oGoodsSize).parents("li").attr("cartitemid");
                            var productId = oGoodsSize.eq(index_oGoodsSize).parents("li").attr("productId");
                            var oSumPrice = $(".js_sumPrice");
                            //总价格
                            var oTaxSum = $(".js_taxSum");
                            // 总的税费
                            if (selectedProductId == "" || selectedProductId == undefined) {
                                selectedProductId = productId;
                            }
                            G_JSON_POST("/shop/cartItem/changeProduct", {
                                productId: selectedProductId,
                                quantity: _num,
                                cartId: cartId
                            }, function(data) {
                                if (data.status = "success") {
                                    var newCartId = data.obj.newCartId;
                                    oGoodsSize.eq(index_oGoodsSize).find(".js_sizeShow").text(_size);
                                    oGoodsSize.eq(index_oGoodsSize).parents(".js_carListArea").find(".js_goodsPrice").text(_price).attr("pprice", _price);
                                    oGoodsSize.eq(index_oGoodsSize).parents(".js_carListArea").find(".js_sumNum").val(_num);
                                    oGoodsSize.eq(index_oGoodsSize).parents(".js_carListArea").find(".js_lazyImg ").attr("src", _img);
                                    oGoodsSize.eq(index_oGoodsSize).parents("li").attr("productId", selectedProductId);
                                    oGoodsSize.eq(index_oGoodsSize).parents("li").attr("cartitemid", newCartId);
                                    // 修改税费
                                    var oTaxrateCar = oGoodsSize.eq(index_oGoodsSize).parents("li").find(".js_taxDelCar");
                                    if (oTaxrateCar && oTaxrateCar.length > 0) {
                                        var nTaxrateCar = oTaxrateCar.attr("taxrate") * 1;
                                        oTaxrateCar.html((nTaxrateCar * _num).toFixed(2));
                                    }
                                    // 总的税费
                                    myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_taxDelCar", oTaxSum);
                                    // 总的价格
                                    myPub.ShopSumPrice($(".js_carList").find(".js_checkBox"), ".js_carListArea", ".js_goodsPrice", oSumPrice);
                                }
                            });
                            oGoodsSizeSide.hide();
                            oShadow.hide();
                        }
                    });
                    myPub.HamstopPropaga();
                });
            },
            // 购物车列表点击出现弹层获的数据
            setLayerData: function(obj, cartId, productId, price, sumNum, fn) {
                var _this = this;
                var product = null;
                getSelectProduct(productId, function(data) {
                    product = data;
                    if (obj.hasClass("act_moreSize")) {
                        // oMoreSizeSide
                        G_JSON_POST("/shop/cartItem/getSkuData", {
                            cartItemId: cartId
                        }, function(data) {
                            if ("success" == data.status) {
                                //拼接规格页面
                                var goods = data.obj.goods;
                                //商品信息
                                var goodsSpecMap = data.obj.goodsSpecMap;
                                //属性信息
                                var productList = data.obj.productList;
                                //属性列表
                                var type = "DGG";
                                var iavPathArrays = [];
                                var specProductDates = {};
                                //多规格 iavPath
                                var productDatas = {};
                                //单规格  productId
                                for (var index in productList) {
                                    if (productList[index].iavPath != "") {
                                        specProductDates[productList[index].iavPath] = {
                                            store: productList[index].cbuyStore,
                                            salePrice: productList[index].salePrice.toFixed(2),
                                            memberPrice: productList[index].memberPrice.toFixed(2),
                                            memberCostScore: productList[index].costMemberScore,
                                            productId: productList[index].id,
                                            name: productList[index].name,
                                            imgPath: HTTP_IMAGE_URL + productList[index].imgPath
                                        };
                                    }
                                }
                                for (var index in productList) {
                                    iavPathArrays.push(productList[index].iavPath);
                                }
                                for (var index in productList) {
                                    productDatas[productList[index].id] = {
                                        store: productList[index].cbuyStore,
                                        salePrice: productList[index].salePrice.toFixed(2),
                                        memberPrice: productList[index].memberPrice.toFixed(2),
                                        memberCostScore: productList[index].costMemberScore,
                                        name: productList[index].name,
                                        imgPath: HTTP_IMAGE_URL + productList[index].imgPath
                                    };
                                }
                                //idArrays = product.iavPath.split(",");
                                var html = appendSkuPage(goods, goodsSpecMap, productList, product, type, price, sumNum);
                                oMoreSizeSide.find(".js_appendSKU").empty().append(html);
                                oSideScroll_moreSize.DelScroll();
                                oSideScroll_moreSize.AddScroll(oMoreSizeSide.find(".js_goodsSizeList")[0]);
                                SumEvent.SumPriceEvent();
                                seletSize.initEvent();
                                if (fn) fn(iavPathArrays, specProductDates, productDatas);
                            }
                        });
                    } else if (obj.hasClass("act_fixedSize")) {}
                });
            },
            // 判断显示弹框选择
            JudgeSizeSide: function(obj, iavPathArrays, specProductDates, productDatas) {
                var _this = this;
                if (obj.hasClass("act_moreSize")) {
                    oMoreSizeSide.show().stop().animate({
                        bottom: 0
                    }, 250, function() {
                        oSideScroll_moreSize.ReScroll();
                        _this.moreSize(iavPathArrays, specProductDates, productDatas);
                    });
                } else if (obj.hasClass("act_fixedSize")) {
                    oFixedSizeSide.show().stop().animate({
                        bottom: 0
                    }, 250, function() {
                        oSideScroll_fixedSize.ReScroll();
                        _this.fixedSize(flowerNumber);
                    });
                }
                oShadow.show();
            },
            // 多规格选择
            moreSize: function(iavPathArrays, specProductDates, productDatas) {
                if (iavPathArrays == undefined) {
                    iavPathArrays = iavPathArraysGoodsDetail;
                }
                if (specProductDates == undefined) {
                    specProductDates = specProductDatesGoodsDetail;
                }
                if (productDatas == undefined) {
                    productDatas = productDatasGoodsDetail;
                }
                var _this = this;
                var GoodsSizemob = oMoreSizeSide.find(".js_goodsSizemob");
                var oUser_seleted = oMoreSizeSide.find(".js_user_seleted");
                _this.moreSizeInit(GoodsSizemob, oUser_seleted, iavPathArrays, specProductDates);
                GoodsSizemob.find("li").hammer().off("tap");
                GoodsSizemob.find("li").hammer().on("tap", function() {
                    var _num = GoodsSizemob.length;
                    var _parent = $(this).parents(".js_goodsSizemob");
                    var parentIndex = _parent.index();
                    var _countLi = _parent.find("li");
                    var index = _countLi.index($(this));
                    if ($(this).hasClass("active-over")) {
                        myPub.TipLayer("该商品已经没有库存啦~");
                    } else {
                        _countLi.removeClass("active").eq(index).addClass("active");
                        _this.moreSizeInit(GoodsSizemob, oUser_seleted, iavPathArrays, specProductDates);
                        //获取多规格 id数组
                        iavPath = "";
                        //使用前初始化
                        //getIdArray($(this),parentIndex);
                        // 表示全部选择了规格 需要获取 库存
                        if (GoodsSizemob.find("li.active").length === _num) {
                            if (_num > 1) {
                                getMultiProductStock($(this), parentIndex, iavPathArrays, specProductDates);
                                $(this).parents(".js_goodsSizeSide ").find(".js_sumNum ").val(1);
                            } else {
                                getStock($(this), productDatas);
                                $(this).parents(".js_goodsSizeSide ").find(".js_sumNum ").val(minNum);
                            }
                        }
                    }
                    myPub.HamstopPropaga();
                });
            },
            // 任选规格
            fixedSize: function(num) {
                var _this = this;
                var aList = [];
                var aListName = [];
                var aOtherName = [];
                var GoodsSizemob = oFixedSizeSide.find(".js_goodsSizemob");
                var oUser_seleted = oFixedSizeSide.find(".js_user_seleted");
                var oTherSize = oFixedSizeSide.find(".js_otherSize");
                num = parseInt(num);
                _this.fixedSizeInit(GoodsSizemob, aList);
                // 规格选择
                GoodsSizemob.find("li").hammer().off("tap");
                GoodsSizemob.find("li").hammer().on("tap", function() {
                    var _countLi = GoodsSizemob.find("li");
                    var index = _countLi.index($(this));
                    if ($(this).hasClass("active-over")) {
                        myPub.TipLayer("该商品已经没有库存啦~");
                        return;
                    } else {
                        if ($(this).hasClass("active")) {
                            $(this).removeClass("active");
                            myPub.removeArrayChildren(aList, index);
                            myPub.removeArrayChildren(aListName, $(this).text());
                        } else {
                            $(this).addClass("active");
                            aList.push(index);
                            aListName.push($(this).text());
                            if (aList.length > num) {
                                aList.splice(0, 1);
                                aListName.splice(0, 1);
                                _countLi.removeClass("active");
                                for (var i = 0; i < aList.length; i++) {
                                    _countLi.eq(aList[i]).addClass("active");
                                }
                            }
                        }
                        if (aList.length === num) {
                            oSeletNumBtn.hide();
                            oOKBtn.show();
                        } else {
                            oSeletNumBtn.show().text("还可以选择" + (num - aList.length) + "件");
                            oOKBtn.hide();
                        }
                        oUser_seleted.find(".js_seletSize").text(aListName);
                        //改变价格和库存
                        getStock($(this), productDatasGoodsDetail);
                    }
                    myPub.HamstopPropaga();
                });
                // 工具选择
                oTherSize.find("li").hammer().off("tap");
                oTherSize.find("li").hammer().on("tap", function() {
                    if ($(this).hasClass("active-over")) {
                        myPub.TipLayer("该商品已经没有库存啦~");
                    } else {
                        if ($(this).hasClass("active")) {
                            $(this).removeClass("active");
                            myPub.removeArrayChildren(aOtherName, $(this).text());
                        } else {
                            $(this).addClass("active");
                            aOtherName.push($(this).text());
                        }
                        oUser_seleted.find(".js_seletOther").text(aOtherName);
                        //改变价格和库存
                        getStock($(this), productDatasGoodsDetail);
                    }
                    myPub.HamstopPropaga();
                });
            },
            // 获取库存和价格  单规格
            getStock: function(target) {},
            // 任选初始化数组
            fixedSizeInit: function(GoodsSizemob, array) {
                if (GoodsSizemob.find("li.active").length > 0) {
                    var _activeLi = GoodsSizemob.find("li.active");
                    _activeLi.each(function(i) {
                        array.push(GoodsSizemob.find("li").index(_activeLi.eq(i)));
                    });
                    return array;
                }
            },
            // 多规格初始化
            moreSizeInit: function(GoodsSizemob, oUser_seleted, iavPathArrays, specProductDates) {
                var _aActName = [];
                idArrays = [];
                //使用前初始化一次
                if (GoodsSizemob.find("li.active").length > 0) {
                    var _activeLi = GoodsSizemob.find("li.active");
                    _activeLi.each(function(i) {
                        _aActName.push(_activeLi.eq(i).text());
                        //将详情页的默认规格选择以后加入idArrays
                        idArrays.push(_activeLi.eq(i).attr("value"));
                    });
                    //console.log("%o  %o  %o",idArrays,iavPathArrays,specProductDates);
                    if (GoodsSizemob.find("li.active").length === GoodsSizemob.length && GoodsSizemob.length > 1) {
                        getMultiProductStock(null, null, iavPathArrays, specProductDates);
                        // 检查是否需要灰选
                        var iavGroup = {};
                        GoodsSizemob.each(function() {
                            var $goodsSizeDiv = $(this);
                            var groupId = $goodsSizeDiv.attr("id");
                            $goodsSizeDiv.find("li").each(function() {
                                var $li = $(this);
                                var liId = $li.attr("value");
                                iavGroup[liId] = groupId;
                            });
                        });
                        var iavArrays = [];
                        /*
                        for(var idx=0;idx<iavPathArrays.length;idx++){
                            var ivaPath = iavPathArrays[idx];
                            var ivaArray = ivaPath.split(",");
                            iavArrays.push(ivaArray);
                        }
                        */
                        for (var ivaPath in specProductDates) {
                            var specProductDate = specProductDates[ivaPath];
                            if (specProductDate.store <= 0) {
                                continue;
                            }
                            var ivaArray = ivaPath.split(",");
                            iavArrays.push(ivaArray);
                        }
                        GoodsSizemob.find("li").each(function() {
                            var $li = $(this);
                            var liId = $li.attr("value");
                            var match = false;
                            for (var idx = 0; idx < iavArrays.length; idx++) {
                                var ivaArray = iavArrays[idx];
                                if ($.inArray(liId, ivaArray) == -1) {
                                    continue;
                                }
                                var otherMatch = true;
                                for (var jj = 0; jj < idArrays.length; jj++) {
                                    var id = idArrays[jj];
                                    if (iavGroup[liId] == iavGroup[id]) {
                                        continue;
                                    }
                                    if ($.inArray(id, ivaArray) == -1) {
                                        otherMatch = false;
                                        break;
                                    }
                                }
                                if (otherMatch) {
                                    match = true;
                                }
                            }
                            if (match) {
                                $li.removeClass("active-over");
                            } else {
                                $li.addClass("active-over");
                            }
                        });
                    }
                    oUser_seleted.find(".js_seletSize").text(_aActName);
                }
            }
        };
        seletSize.init();
    }
    //商品最小购买数量
    var goodschannel = $("#goodschannel").val();
    var recRequestId = $("#recRequestId").val();
    var sceneType = $("#sceneType").val();
    var regionId = $("#regionId").length > 0 ? $("#regionId").val() : "";
    var flowerNumber = $("#flowerNumber").val();
    var minNum = 1;
    var minCount = $(".jsMinCount");
    var selectedProductId = "";
    if (minCount.attr("minCount") != null && minCount.attr("minCount") != undefined) {
        minNum = parseInt(minCount.attr("minCount"));
    }
    // 初始化税费
    if (oTaxDelArea && oTaxDelArea.length > 0) {
        taxRate = oTaxDelArea.parents(".js_chooseNumArea").siblings(".js_goodsSizeList").find("li.active").attr("taxfare");
        if (taxRate && taxRate != undefined && taxRate != "") {
            taxRate = taxRate * 1 * minNum;
        } else {
            taxRate = 0;
        }
        oTaxDel.text("￥" + taxRate.toFixed(2));
    } else {
        taxRate = 0;
    }
    // 获取库存和价格  单规格
    function getStock(target, productDatas) {
        var $thisId = target.attr("id");
        var oTaxDelArea = $(".js_taxDelArea");
        // 显示税费区域
        var oTaxDel = $(".js_taxDel");
        // 显示税费数字
        var taxPriceNum = 0;
        // 税费金额
        var taxRate = 0;
        // 税费单价
        // if ($thisId == selectedProductId) {
        //     return false;
        // }
        $("#quantity").val(minNum);
        selectedProductId = $thisId;
        // 税费
        if (oTaxDelArea && oTaxDelArea.length > 0) {
            taxRate = target.parents(".js_goodsSizeList").find("li.active").attr("taxfare");
            if (taxRate && taxRate != undefined && taxRate != "") {
                taxRate = taxRate * 1;
            } else {
                taxRate = 0;
            }
        } else {
            taxRate = 0;
        }
        //变更库存
        $(".kucun").attr("value", productDatas[selectedProductId].store);
        $(".kucun").html(productDatas[selectedProductId].store);
        //规格值
        $(".hasChoose").attr("value", productDatas[selectedProductId].name);
        $(".hasChoose").html(productDatas[selectedProductId].name);
        var oDefaultFanxian = $(".js_default_fanxian");
        var oHJmember = $("#HJmember").val();
        if ($("#costMemberScore").length > 0) {
            // 税费
            taxPriceNum = (minNum * taxRate).toFixed(2) * 1;
            oTaxDel.text("￥" + taxPriceNum.toFixed(2));
            $("#salePrice").attr("pprice", productDatas[selectedProductId].memberPrice);
            $("#salePrice").html((productDatas[selectedProductId].memberPrice * minNum).toFixed(2));
            $("#costMemberScore").html(productDatas[selectedProductId].memberCostScore * minNum);
            $("#costMemberScore").attr("costMemberScore", productDatas[selectedProductId].memberCostScore);
            if (productDatas[selectedProductId].isReturnMoney == "true" && productDatas[selectedProductId].returnMoneyPercentage != null && productDatas[selectedProductId].saleModel != 1) {
                if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                    oDefaultFanxian.show();
                }
                $("#returnMoney").html((productDatas[selectedProductId].returnMoneyPercentage * productDatas[selectedProductId].memberPrice * minNum / 100).toFixed(2));
                $("#salePrice").attr("returnMoneyPercentage", productDatas[selectedProductId].returnMoneyPercentage);
            } else {
                if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                    oDefaultFanxian.hide();
                }
                $("#salePrice").removeAttr("returnMoneyPercentage");
            }
        } else {
            // 税费
            taxPriceNum = (minNum * taxRate).toFixed(2) * 1;
            oTaxDel.text("￥" + taxPriceNum.toFixed(2));
            $("#salePrice").attr("pprice", productDatas[selectedProductId].salePrice);
            if (productDatas[selectedProductId].isJifen == "true" && productDatas[selectedProductId].memberPoint > 0) {
                if (productDatas[selectedProductId].salePrice == 0) {
                    $("#salePrice").html(productDatas[selectedProductId].memberPoint * minNum + "积分");
                } else {
                    $("#salePrice").html((productDatas[selectedProductId].salePrice * minNum).toFixed(2) + "+" + productDatas[selectedProductId].memberPoint * minNum + "积分");
                    if (productDatas[selectedProductId].isReturnMoney == "true" && productDatas[selectedProductId].returnMoneyPercentage != null && productDatas[selectedProductId].saleModel != 1) {
                        if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                            oDefaultFanxian.show();
                        }
                        $("#returnMoney").html((productDatas[selectedProductId].returnMoneyPercentage * productDatas[selectedProductId].salePrice * minNum / 100).toFixed(2));
                        $("#salePrice").attr("returnMoneyPercentage", productDatas[selectedProductId].returnMoneyPercentage);
                    } else {
                        if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                            oDefaultFanxian.hide();
                        }
                        $("#salePrice").removeAttr("returnMoneyPercentage");
                    }
                }
                $("#salePrice").attr("jifen", productDatas[selectedProductId].memberPoint);
            } else {
                //购物返现
                if (productDatas[selectedProductId].isReturnMoney == "true" && productDatas[selectedProductId].returnMoneyPercentage != null && productDatas[selectedProductId].saleModel != 1) {
                    if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                        oDefaultFanxian.show();
                    }
                    $("#salePrice").html((productDatas[selectedProductId].salePrice * minNum).toFixed(2));
                    $("#salePrice").attr("returnMoneyPercentage", productDatas[selectedProductId].returnMoneyPercentage);
                    $("#returnMoney").html((productDatas[selectedProductId].returnMoneyPercentage * minNum * productDatas[selectedProductId].salePrice / 100).toFixed(2));
                } else {
                    if (oDefaultFanxian.length > 0 && oHJmember == "HJmember") {
                        oDefaultFanxian.hide();
                    }
                    if (productDatas[selectedProductId].saleModel == 1) {
                        $("#salePrice").html(productDatas[selectedProductId].salePrice);
                    } else {
                        $("#salePrice").html((productDatas[selectedProductId].salePrice * minNum).toFixed(2));
                    }
                    $("#salePrice").removeAttr("returnMoneyPercentage");
                }
                $("#salePrice").removeAttr("jifen");
            }
        }
        if (productDatas[selectedProductId].imgPath != HTTP_IMAGE_URL && productDatas[selectedProductId].imgPath != HTTP_IMAGE_URL + "null") {
            $("#currentImg").attr("src", productDatas[selectedProductId].imgPath);
            $("#currentImg").html(productDatas[selectedProductId].imgPath);
        }
    }
    // 获取库存和价格  多规格
    var tapFlag = false;
    var idArrays = [];
    // var specLength = oneIavPth.split(",").length;//默认商品 iavpath剪切后的长度
    var iavPath = "";
    //product的iavPath属性
    function getIdArray(obj, specIndex) {
        if (idArrays.length >= specIndex) {
            idArrays.splice(specIndex, 1, obj.val());
        } else {
            for (var i = 0; i < specIndex; i++) {
                idArrays.push(0);
            }
            idArrays.splice(specIndex, 1, obj.val());
        }
    }
    //获取多规格未选择的li父级html
    function getLiParentHtml() {
        var obj = $(".js_goodsSizemob");
        var objLeng = $(".js_goodsSizemob[id]").length;
        for (var i = 0; i <= objLeng - 1; i++) {
            var objP = $(".js_goodsSizemob[id =" + i + "]  p").text();
            var objLi = $(".js_goodsSizemob[id =" + i + "] li");
            if (!objLi.hasClass("active")) {
                myPub.TipLayer("请选择商品" + objP);
                return false;
            }
        }
    }
    function getMultiProductStock(obj, specIndex, iavPathArrays, specProductDates) {
        iavPath = "";
        // idArrays.length == specLength &&
        if ($.inArray(0, idArrays) == -1) {
            //拼接选中的规格 id
            for (var i = 0; i < idArrays.length; i++) {
                if (i < idArrays.length - 1) {
                    iavPath += idArrays[i] + ",";
                } else {
                    iavPath += idArrays[i];
                }
            }
            //当iavPath与后台参数一致的时候  进行下列逻辑
            iavPath = isInclude(iavPath, iavPathArrays);
            if (iavPath != "") {
                selectedProductId = specProductDates[iavPath].productId;
                if (specProductDates[iavPath].store > 0) {
                    $(".kucun").attr("value", specProductDates[iavPath].store);
                    $(".kucun").html(specProductDates[iavPath].store);
                    //规格值
                    $(".hasChoose").attr("value", specProductDates[iavPath].name);
                    $(".hasChoose").html(specProductDates[iavPath].name);
                    $(".js_OKBtn").removeClass("btn_Bghui btn_Bggray");
                    tapFlag = false;
                    $(".js_OKBtn").html("确定");
                } else {
                    $(".kucun").attr("value", 0);
                    $(".kucun").html(0);
                    //规格值
                    $(".hasChoose").attr("value", specProductDates[iavPath].name);
                    $(".hasChoose").html(specProductDates[iavPath].name);
                    $(".js_OKBtn").addClass("btn_Bghui btn_Bggray");
                    if ($(".js_OKBtn").hasClass("btn_Bggray")) {
                        tapFlag = true;
                    }
                    $(".js_OKBtn").html("无货");
                }
                if ($("#costMemberScore").length > 0) {
                    $("#salePrice").attr("pprice", specProductDates[iavPath].memberPrice);
                    $("#salePrice").html(specProductDates[iavPath].memberPrice);
                    $("#costMemberScore").html(specProductDates[iavPath].memberCostScore);
                } else {
                    $("#salePrice").attr("pprice", specProductDates[iavPath].salePrice);
                    if (specProductDates[iavPath].isJifen == "true" && specProductDates[iavPath].memberPoint > 0) {
                        if (specProductDates[iavPath].salePrice == 0) {
                            $("#salePrice").html(specProductDates[iavPath].memberPoint + "积分");
                        } else {
                            $("#salePrice").html(specProductDates[iavPath].salePrice + "+" + specProductDates[iavPath].memberPoint + "积分");
                        }
                        $("#salePrice").attr("jifen", specProductDates[iavPath].memberPoint);
                    } else {
                        $("#salePrice").html(specProductDates[iavPath].salePrice);
                        $("#salePrice").removeAttr("jifen");
                    }
                }
                if (specProductDates[iavPath].imgPath != HTTP_IMAGE_URL && specProductDates[iavPath].imgPath != HTTP_IMAGE_URL + "null") {
                    $("#currentImg").attr("src", specProductDates[iavPath].imgPath);
                    $("#currentImg").html(specProductDates[iavPath].imgPath);
                }
            } else {
                $(".js_OKBtn").addClass("btn_Bghui btn_Bggray");
                if ($(".js_OKBtn").hasClass("btn_Bggray")) {
                    tapFlag = true;
                }
                $(".js_OKBtn").html("无货");
                $(".kucun").attr("value", 0);
                $(".kucun").html(0);
                selectedProductId = -1;
            }
        }
    }
    //拼接弹出层SKU页面
    function appendSkuPage(goods, goodsSpecMap, productList, product, type, price, sumNum) {
        var html = "";
        var sfMemberHtml = "";
        if (goods.memberPrice == "true") {
            if (product.costMemberScore > 0) {
                sfMemberHtml = '<span class="goodsPrice js_goodsPrice" id="salePrice" pprice="' + product.memberPrice + '">' + price + "</span>" + '<span class="color_hui jsGoodsCostMemberScore" style="margin-left: 0.5rem">+<span id="costMemberScore">' + product.costMemberScore + "</span>积分</span>";
            }
        } else {
            sfMemberHtml = ' <span id="salePrice" class="goodsPrice js_goodsPrice"  pprice="' + product.salePrice + '">' + price + "</span>";
        }
        var skuChooseHtml = "";
        if (goods.isSpecificationEnabled) {
            var itemAttrKeyHtml = getItemAttrKeyHtml(goodsSpecMap, product);
            skuChooseHtml = '<section class="goodsSizeList js_goodsSizeList VBox Bflex1">' + '<section class="goodsSizeBox js_goodsSizeBox Bflex1" >' + itemAttrKeyHtml + "</section></section>";
        } else {
            var productListHtml = getProductListHtml(productList, product);
            skuChooseHtml = '<section class="goodsSizeList js_goodsSizeList VBox Bflex1">' + '<section class="goodsSizeBox js_goodsSizeBox Bflex1" >' + '<div class="goodsSizemob js_goodsSizemob" id="0">' + '<p class="sideTitle">规格选择:</p>' + '<ul class="Bflex1 clearfix">' + productListHtml + "</ul></div></section></section>";
        }
        var chooseNumHtml = getChooseNumHtml(goods, sumNum);
        var productImg;
        var defaultImage = getDefaultImage(goods);
        if (product.imgPath != null && product.imgPath != "") {
            productImg = product.imgPath;
        } else {
            productImg = defaultImage;
        }
        if ("RX" == type) {} else {
            // 添加商品税费区域
            var taxHtml = "";
            for (var index in productList) {
                if (productList[index].id == product.id && productList[index].calGlobalFee && productList[index].calGlobalFee != null && productList[index].cbuyStore > 0) {
                    var nTaxRare = (productList[index].calGlobalFee * sumNum).toFixed(2);
                    taxHtml = '   <div class="buyGoodsNum HBox spBe flexBox taxDelArea js_taxDelArea">' + "       <div>商品税费</div>" + '       <div class="js_taxDel" >￥' + nTaxRare + "</div>" + "   </div>";
                } else {
                    taxHtml = "";
                }
            }
            html = '<section class="goodsSmallImg js_goodsSmallImg HBox BoxCenter">' + '       <figure class="goodsImg ">' + '           <img id="currentImg" src="' + HTTP_IMAGE_URL + "" + productImg + smallImgArg200 + '" alt="">' + "       </figure>" + '<div class="Bflex1">' + '<p class="priceAreaBox">' + '<i class="units">￥</i>' + sfMemberHtml + "</p>" + '<p class="">库存：<span class="kucun" value="' + product.cbuyStore + '">' + product.cbuyStore + "</span>份</p>" + '<p class="user_seleted js_user_seleted">已选择：<span class="hasChoose" value="' + product.name + '">' + product.name + "</span></p>" + "</div></section>" + skuChooseHtml + '<div class="transnationalTax js_chooseNumArea">' + '   <section class="buyGoodsNum HBox BoxCenter ">' + '       <p class="sideTitle Bflex1">请选择数量</p>' + '       <div class="amountBox HBox js_amountBox BoxCenter ">' + chooseNumHtml + "       </div>" + "   </section>" + // BC清关
            taxHtml + "</div>" + "</section>";
            return html;
        }
    }
    /**
     * 获取默认规格
     */
    // function getOneProduct(goods){
    //     for(var index in goods.productList){
    //         if(goods.productList[index].isDefault){
    //             return goods.productList[index];
    //         }
    //     }
    //     return goods.productList[0];
    // }
    /**
     * 获取选中规格
     */
    function getSelectProduct(productId, fn) {
        G_JSON_POST("/shop/cartItem/getSelectProduct", {
            productId: productId
        }, function(data) {
            if (data.status = "success") {
                if (fn) fn(data.obj);
            }
        });
    }
    /**
     * 获取默认图片
     * @param goods
     * @returns {*}
     */
    function getDefaultImage(goods) {
        if (goods.goodsImagePath != "") {
            var defaultImage = goods.goodsImagePath.split(",");
            return defaultImage[0];
        }
        return "";
    }
    //多规格拼接属性名
    function getItemAttrKeyHtml(goodsSpecMap, product) {
        var html = "";
        var index = 0;
        for (var itemKey in goodsSpecMap) {
            var itemAttrValueHtml = getItemAttrValueHtml(goodsSpecMap[itemKey], product);
            var jsonItemKey = JSON.parse(itemKey);
            html += '<div class="goodsSizemob js_goodsSizemob" id="' + index + '">' + '<p class="sideTitle" value="' + jsonItemKey.id + '">' + jsonItemKey.iakName + ":</p>" + '<ul class="Bflex1 clearfix">' + itemAttrValueHtml + "</ul></div>";
            index++;
        }
        return html;
    }
    //多规格拼接属性值
    function getItemAttrValueHtml(itemAttrValueList, product) {
        var iavPath = product.iavPath.split(",");
        var html = "";
        for (var index in itemAttrValueList) {
            if ($.inArray(itemAttrValueList[index].id + "", iavPath) != -1) {
                html += '<li class="active" value="' + itemAttrValueList[index].id + '" >' + itemAttrValueList[index].iavValue + "</li>";
            } else {
                html += '<li value="' + itemAttrValueList[index].id + '" >' + itemAttrValueList[index].iavValue + "</li>";
            }
        }
        return html;
    }
    //单规格拼接SKU
    function getProductListHtml(productList, product) {
        var html = "";
        for (var index in productList) {
            if (productList[index].id == product.id && productList[index].cbuyStore > 0) {
                if (productList[index].cbuyStore == 0) {
                    html += '<li  class="active" taxFare="' + productList[index].calGlobalFee + '" id="' + productList[index].id + '"  mutliStore="' + productList[index].cbuyStore + '"  class="active-over">' + productList[index].name + "</li>";
                } else {
                    html += '<li  class="active" taxFare="' + productList[index].calGlobalFee + '" id="' + productList[index].id + '"  mutliStore="' + productList[index].cbuyStore + '" >' + productList[index].name + "</li>";
                }
            } else {
                if (productList[index].cbuyStore == 0) {
                    html += '<li taxFare="' + productList[index].calGlobalFee + '" id="' + productList[index].id + '"  mutliStore="' + productList[index].cbuyStore + '" class="active-over" >' + productList[index].name + "</li>";
                } else {
                    html += '<li taxFare="' + productList[index].calGlobalFee + '" id="' + productList[index].id + '"  mutliStore="' + productList[index].cbuyStore + '"  >' + productList[index].name + "</li>";
                }
            }
        }
        return html;
    }
    //拼接弹出层数量
    function getChooseNumHtml(goods, sumNum) {
        var html = "";
        var minCount = goods.minCount;
        var maxCount = goods.xgCount;
        if (minCount != "" && minCount != undefined && minCount < 1) {
            minCount = 1;
        }
        if (goods.xgCount == 1 || goods.goodsLabels == "WEIXIN_NEW_USER" || goods.goodsLabels == "NWE_USER") {
            html = '<button class="numBtn js_handBtn active" type="button">-</button>' + '<input  id="quantity" class="sumNum js_sumNum jsMinCount" type="number" name="" minCount = "' + minCount + '" maxCount = "' + maxCount + '" value="1"  readOnly="true"/>' + '<button class="numBtn js_handBtn" type="button">+</button>';
        } else {
            html = '<button class="numBtn js_handBtn active" type="button">-</button>' + '<input  id="quantity" class="sumNum js_sumNum jsMinCount" type="number" name="" minCount = "' + minCount + '"  maxCount = "' + maxCount + '" value="' + sumNum + '" />' + '<button class="numBtn js_handBtn" type="button">+</button>';
        }
        return html;
    }
    /**
     * 获取iavPath
     * @param {Object} ivaPath 88,89,90,92,91
     * @param {Object} ivaPathArray ["88,89,90,91,92", "88,89,90,91,93"]
     */
    function isInclude(ivaPath, ivaPathArray) {
        if (ivaPathArray && ivaPath) {
            var ivasLen = ivaPathArray.length;
            if (ivasLen == 0) {
                return "";
            }
            var ivaPaths = ivaPath.split(","), ivaPathsLen = ivaPaths.length, ivaPathsLenjj = ivaPathsLen - 1;
            for (var i = 0; i < ivasLen; i++) {
                var ivaPathA = ivaPathArray[i], ivaPathArrays = ivaPathA.split(","), ivaPathArraysLen = ivaPathArrays.length;
                var isIncludeArray = false;
                for (var j = 0; j < ivaPathsLen; j++) {
                    var isIncludeArrays = false;
                    for (var a = 0; a < ivaPathArraysLen; a++) {
                        if (ivaPaths[j] == ivaPathArrays[a]) {
                            isIncludeArrays = true;
                            break;
                        }
                    }
                    if (isIncludeArrays == false) {
                        break;
                    } else {
                        if (j == ivaPathsLenjj && isIncludeArrays) {
                            isIncludeArray = isIncludeArrays;
                            break;
                        }
                    }
                }
                if (isIncludeArray == true) {
                    return ivaPathArray[i];
                }
            }
        }
        return "";
    }
    // 添加用户行为
    function userAction(obj, mode, keyword) {
        ddjhoc.setData(obj, mode, "add", function() {
            console.log("params." + mode, ddjhoc.params);
            ddjhoc.sendData(ddjhoc.params);
        }, keyword);
    }
    exports.GoodsSizeSelet = GoodsSizeSelet;
});
var baseurl = "";

var smallImgArg = "?x-oss-process=style/goods_img_3";

var smallImgArg300 = "?x-oss-process=style/goods_img_2";

var smallImgArg200 = "?x-oss-process=style/goods_img";

function check_support_webp() {
    var isSupportWebp = document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") == 0;
    return isSupportWebp;
}

if (check_support_webp()) {
    smallImgArg = "?x-oss-process=style/goods_webp_3";
    smallImgArg300 = "?x-oss-process=style/goods_webp_2";
    smallImgArg200 = "?x-oss-process=style/goods_webp";
}

define("static_v4/js/mod/public", [], function(require, exports, module) {
    //yx
    //var httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
    //zs
    //var httpImageUrl="https://sfddj-img-bucket.oss-cn-shenzhen.aliyuncs.com/";
    var httpImageUrl;
    var myDoMain = "";
    if (window.location.host == "m.sfddj.com" || window.location.host == "120.76.47.184" || window.location.host == "120.76.207.85" || window.location.host == "120.76.44.28") {
        // httpImageUrl="https://sfddj-img-bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.sfddj.com/";
        myDoMain = "https://m.sfddj.com";
    } else if (window.location.host == "hdm.sfddj.com") {
        httpImageUrl = "https://img.sfddj.com/";
        myDoMain = "https://hdm.sfddj.com";
    } else if (window.location.host == "itsm.sfddj.com") {
        // httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://itsm.sfddj.com";
    } else if (window.location.host == "shop.fx-sf.com") {
        // httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://shop.fx-sf.com";
    } else if (window.location.host == "www.shhyxypsx.com") {
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://www.shhyxypsx.com";
    } else if (window.location.hostname == "localhost") {
        httpImageUrl = "http://img-dev.sfddj.com/";
        myDoMain = "http://localhost:8082";
    }
    exports.httpImageUrl = httpImageUrl;
    exports.myDoMain = myDoMain;
    //加入购物车的动画
    function AddCarAnimate(_X, _Y, target, sLeft, sTop, offsetDis, callBack) {
        // var _X = e.gesture.center.x;
        // var _Y = e.gesture.center.y;
        var time = null;
        var timeTwo = null;
        target.removeClass("myRotateFast");
        target.css({
            left: _X,
            top: _Y,
            opacity: 1
        });
        clearTimeout(time);
        time = setTimeout(function() {
            target.addClass("myRotateFast").stop().animate({
                left: _X,
                top: _Y - 50,
                opacity: 1
            }, 300, function() {
                target.stop().animate({
                    left: sLeft,
                    top: sTop
                }, 600, function() {
                    target.removeClass("myRotateFast");
                    clearTimeout(timeTwo);
                    timeTwo = setTimeout(function() {
                        target.stop().animate({
                            top: sTop + offsetDis * 2,
                            opacity: 0
                        }, 200, function() {
                            if (callBack) callBack();
                        });
                    }, 200);
                });
            });
        }, 30);
    }
    exports.AddCarAnimate = AddCarAnimate;
    // hammer 冒泡
    function HamstopPropaga() {
        window.event.returnValue = false;
        return false;
    }
    exports.HamstopPropaga = HamstopPropaga;
    //hammer事件
    function HammerEvent(obj) {
        this.obj = obj;
    }
    HammerEvent.prototype.addHamEvent = function(obj, type, fn) {
        this.obj = new Hammer.Manager(obj);
        this.obj.add(new Hammer.Pan({
            velocity: 0,
            threshold: 120,
            direction: Hammer.DIRECTION_ALL
        }));
        //平滑
        this.obj.add(new Hammer.Swipe({
            threshold: 8,
            direction: Hammer.DIRECTION_ALL
        }));
        this.obj.add(new Hammer.Tap({}));
        this.obj.add(new Hammer.Press({
            velocity: .6,
            threshold: 8
        }));
        //长时间下压
        this.obj.off(type);
        this.obj.on(type, function(e) {
            if (fn) fn(e);
        });
    };
    exports.HammerEvent = HammerEvent;
    /* 数字验证 */
    function ValiNum(obj, fn1, fn2) {
        var reg = new RegExp("^[0-9]*$");
        if (!reg.test(obj.val())) {
            if (fn1) fn1();
        } else if (obj.val() <= 0) {
            // TipLayer("数量不能小余1");
            obj.val(1);
        } else {
            if (fn2) fn2();
        }
    }
    exports.ValiNum = ValiNum;
    /* 字数统计 */
    function statInputNum(textArea, numItem) {
        var max = [];
        var curLength = [];
        textArea.each(function(i) {
            max[i] = parseInt(numItem.eq(i).text());
            if (textArea.eq(i).val().length > 0) {
                curLength[i] = textArea.eq(i).val().length;
                numItem.eq(i).empty().text(max[i] - curLength[i]);
            }
            textArea.eq(i).attr("maxlength", max[i]).on("input propertychange", function() {
                curLength[i] = $(this).val().length;
                numItem.eq(i).empty().text(max[i] - curLength[i]);
            });
        });
    }
    exports.statInputNum = statInputNum;
    /* 购物车价格统计 */
    function ShopSumPrice(obj, tarFather, target, sumPrice) {
        var _price = 0;
        obj.each(function(i) {
            if (obj.eq(i).hasClass("active")) {
                var _oGoodsPrice = obj.eq(i).parents(tarFather).find(target);
                _oGoodsPrice.each(function(i) {
                    _price += _oGoodsPrice.eq(i).text() * 1;
                    return _price;
                });
            }
        });
        sumPrice.text(_price.toFixed(2));
    }
    exports.ShopSumPrice = ShopSumPrice;
    /*************** 弹框效果 s***************/
    //提示框
    function TipLayer(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shadeClose: false,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayer = TipLayer;
    //提示框_没有遮罩层
    function TipLayer_noShade(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shade: false,
            shadeClose: false,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayer_noShade = TipLayer_noShade;
    //框消失后执行回调提示框
    function TipLayerEnd(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shadeClose: false,
            end: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerEnd = TipLayerEnd;
    // 用户手动关闭弹框
    function TipLayerLong(sCont, sStyle) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            shadeClose: true
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerLong = TipLayerLong;
    // 用户手动关闭弹框有关闭按钮
    function TipLayerLongClose(sTit, sCont, sStyle, fn) {
        layer.open({
            title: sTit != "no" ? sTit : "",
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            shadeClose: true,
            closeBtn: 1,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerLongClose = TipLayerLongClose;
    //带按钮提示框
    function TipBtnLayer(sCont, sTit, btnName, yesFn, cancelFn, fn) {
        layer.open({
            title: sTit != "no" ? sTit : "",
            content: sCont,
            btn: btnName == undefined ? [ "确定" ] : [ btnName ],
            shadeClose: false,
            scrollbar: false,
            yes: function() {
                if (yesFn) yesFn();
                LayerCloseAll();
            },
            cancel: function() {
                if (cancelFn) cancelFn();
            },
            success: function() {
                if (fn) fn();
                $(".layermbtn span").css({
                    width: "100%"
                });
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipBtnLayer = TipBtnLayer;
    // 标题提示框
    function TipTitleLayer(sTitle, styleTit, sCont, fn) {
        layer.open({
            title: [ sTitle, "background-color:#fff; color:#666; font-weight:bold" ],
            content: sCont,
            shadeClose: false,
            scrollbar: false,
            style: styleTit,
            cancel: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipTitleLayer = TipTitleLayer;
    //询问层
    function askLayer(sCont, yesFn, noFn, sTit, callBack, aBtnName) {
        layer.open({
            //no 为没有标题 sTit为设置标题
            title: sTit != "no" ? sTit : "",
            content: sCont,
            btn: aBtnName == undefined ? [ "确认", "取消" ] : aBtnName,
            shadeClose: false,
            scrollbar: false,
            yes: yesFn,
            no: noFn,
            cancel: noFn,
            success: function() {
                if (callBack) callBack();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.askLayer = askLayer;
    // 关闭所有弹框
    function LayerCloseAll() {
        layer.closeAll();
    }
    exports.LayerCloseAll = LayerCloseAll;
    //加载层
    function loadLayer(cont) {
        layer.open({
            type: 2,
            content: cont,
            shadeClose: false
        });
        NoTouchMove($(".laymshade"));
    }
    exports.loadLayer = loadLayer;
    //防止滑动
    function NoTouchMove(obj) {
        obj.on("touchmove", function() {
            return false;
        });
    }
    exports.NoTouchMove = NoTouchMove;
    /*************** 弹框效果 e***************/
    //节流控制
    function throttle(method, context, time) {
        time == undefined ? time = 200 : time = time;
        //console.log(time)
        clearTimeout(method.tId);
        method.tId = setTimeout(function() {
            method.call(context);
        }, time);
    }
    exports.throttle = throttle;
    //s20是代表20秒 h是指小时，如12小时则是：h12 d是天数，30天则：d30
    //写cookies setCookie("name","hayden",'s20');
    function setCookie(name, value, time) {
        var strsec;
        if (time == undefined) {
            var Days = 30;
            //默认30天有效期
            strsec = Days * 24 * 60 * 60 * 1e3;
        } else {
            strsec = getsec(time) * 1;
        }
        var exp = new Date();
        exp.setTime(exp.getTime() + strsec);
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
    }
    exports.setCookie = setCookie;
    //读取cookies getCookie("name")
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }
    exports.getCookie = getCookie;
    //删除cookies delCookie('name')
    function delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = getCookie(name);
        if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/";
    }
    exports.delCookie = delCookie;
    //设置cookie时间
    function getsec(str) {
        var str1 = str.substring(1, str.length) * 1;
        var str2 = str.substring(0, 1);
        if (str2 == "s") {
            return str1 * 1e3;
        } else if (str2 == "h") {
            return str1 * 60 * 60 * 1e3;
        } else if (str2 == "d") {
            return str1 * 24 * 60 * 60 * 1e3;
        }
    }
    /* 验证码倒计时 */
    function CutTime(time, fn1, fn2) {
        var _AllTime = time;
        var _T = null;
        clearInterval(_T);
        _T = setInterval(function() {
            if (time <= 0) {
                clearInterval(_T);
                if (fn1) fn1(_AllTime);
            } else {
                time--;
                if (fn2) fn2(time);
            }
        }, 1e3);
    }
    exports.CutTime = CutTime;
    /*手机号码验证*/
    function checkMobile(obj, fn1, fn2, fn3) {
        var oIphone = obj.val();
        var reg = /^(1[1|2|3|4|5|6|7|8|9])[\d]{9}$/;
        //验证手机号码
        if (oIphone == "") {
            if (fn1) fn1();
        } else if (!reg.test(oIphone)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkMobile = checkMobile;
    /*密码验证*/
    function checkPassWord(obj, fn1, fn2, fn3) {
        var _val = obj.val();
        var reg = /^[a-zA-Z0-9]{6,20}$/;
        //6-20位数字和英文
        if (_val == "") {
            if (fn1) fn1();
        } else if (!reg.test(_val)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkPassWord = checkPassWord;
    /*用户名验证*/
    function checkUserName(obj, fn1, fn2, fn3) {
        var _userName = obj.val();
        var reg = /^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5]{1,9}$/;
        //验证用户名
        if (_userName == "") {
            if (fn1) fn1();
        } else if (!reg.test(_userName)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkUserName = checkUserName;
    //图片预加载(window)
    function lazLoadingImgEcho(obj, fn) {
        echo.init({
            container: obj,
            offset: 300,
            throttle: 50,
            //设置图片延迟加载的时间 
            callback: function(element, op) {
                if (fn) fn(element, op);
                // console.log(element, 'has been', op + 'ed')
                var $el = $(element);
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
            }
        });
    }
    exports.lazLoadingImgEcho = lazLoadingImgEcho;
    function lazLoadingImg(obj) {
        this.obj = obj;
    }
    //添加图片预加载
    lazLoadingImg.prototype.AddLazLoadingImg = function(obj, fn) {
        this.obj = echoChangeByCc.initNew({
            container: obj,
            unload: false,
            offset: 300,
            throttle: 80,
            //设置图片延迟加载的时间
            callback: function(element, op) {
                var $el = $(element);
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
                if (fn) fn();
            }
        });
    };
    // 图片预加载 销毁
    lazLoadingImg.prototype.DestroyLazLoadingImg = function() {
        var _this = this.obj;
        if (_this && _this.detach) {
            _this.detach();
        }
    };
    // 图片预加载 刷新
    lazLoadingImg.prototype.RushLazLoadingImg = function() {
        var _this = this.obj;
        _this.render();
    };
    function loadImageCheck(url, callback) {
        //创建一个Image对象，实现图片的预下载
        var img = new Image();
        img.src = url;
        // 如果图片已经存在于浏览器缓存，直接调用回调函数
        if (img.complete) {
            callback();
            img = null;
            return;
        }
        img.onload = function() {
            //图片下载完毕时异步调用callback函数。
            callback();
            img = null;
        };
    }
    exports.lazLoadingImg = lazLoadingImg;
    function lazLoadingImgEchoAbs(obj, fn) {
        echoChangeByCc.initNew({
            container: obj,
            unload: false,
            offset: 200,
            throttle: 30,
            //设置图片延迟加载的时间
            callback: function(element, op) {
                var $el = $(element);
                // console.log($el)
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
                if (fn) fn();
            }
        });
    }
    exports.lazLoadingImgEchoAbs = lazLoadingImgEchoAbs;
    //mui插件事件开关
    function OffMuiEvent(arg) {
        mui.init({
            gestureConfig: {
                tap: arg,
                //默认为true
                swipe: arg
            }
        });
    }
    exports.OffMuiEvent = OffMuiEvent;
    //设置li图片高度 父级获取
    function SetImgHeight(obj, getWidth) {
        var htmlFontSize = $("html").css("font-size");
        var intSize = htmlFontSize.split("p")[0];
        var imgWidth = null;
        if (obj[0].nodeName.toLowerCase() === "li") {
            getWidth ? imgWidth = getWidth / intSize : imgWidth = obj.find("figure").eq(0).parents("a").width() / intSize;
            // obj.find('figure:not(:first)').css({'height': imgWidth+'rem', 'width': imgWidth+'rem'});
            obj.find("figure").css({
                height: imgWidth + "rem",
                width: imgWidth + "rem"
            });
        } else {
            getWidth ? imgWidth = getWidth / intSize : imgWidth = obj.find("li figure").eq(0).parents("a").width() / intSize;
            // obj.find('li figure:not(:first)').css({'height': imgWidth+'rem', 'width': imgWidth+'rem'});
            obj.find("li figure").css({
                height: imgWidth + "rem",
                width: imgWidth + "rem"
            });
        }
    }
    exports.SetImgHeight = SetImgHeight;
    // 日期 2015-09-01 11:16:00
    function FormatDateTime(date, minType, point) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? "0" + m : m;
        var d = date.getDate();
        d = d < 10 ? "0" + d : d;
        var h = date.getHours();
        h = h < 10 ? "0" + h : h;
        var minute = date.getMinutes();
        minute = minute < 10 ? "0" + minute : minute;
        var seconds = date.getSeconds();
        seconds = seconds < 10 ? "0" + seconds : seconds;
        var _sep = "-";
        if (point) _sep = point;
        // 最小到天
        if (minType == "minDay") {
            return y + _sep + m + _sep + d;
        } else if (minType == "minMinute") {
            return y + _sep + m + _sep + d + " " + h + ":" + minute;
        } else {
            return y + _sep + m + _sep + d + " " + h + ":" + minute + ":" + seconds;
        }
    }
    exports.FormatDateTime = FormatDateTime;
    /*************** 滚动条效果 s***************/
    function ScrollBar(obj) {
        this.obj = obj;
    }
    //添加滚动条
    ScrollBar.prototype.AddScroll = function(obj, sOptions) {
        this.obj = new JRoll(obj, sOptions);
    };
    //刷新滚动条
    ScrollBar.prototype.ReScroll = function(fn) {
        var _this = this.obj;
        _this.refresh();
        if (fn) fn();
    };
    //删除滚动条
    ScrollBar.prototype.DelScroll = function(fn) {
        var _this = this.obj;
        _this.destroy();
        if (fn) fn();
    };
    //滚动 到 0
    ScrollBar.prototype.ScrollTo = function(x, y, time, fn) {
        var _this = this.obj;
        _this.scrollTo(x, y, time, false, function() {
            if (fn) fn(_this);
        });
    };
    //滚动开始事件
    ScrollBar.prototype.ScrollStart = function(fn) {
        var _this = this.obj;
        _this.on("scrollStart", fn);
    };
    //滚动结束事件
    ScrollBar.prototype.ScrollEnd = function(fn1, fn2) {
        var _this = this.obj;
        _this.on("scrollEnd", fn1);
        if (fn2) fn2();
    };
    //滚动监听
    ScrollBar.prototype.ScrollIng = function(fn) {
        var _this = this.obj;
        //this.obj.on('scroll', fn);
        this.obj.on("scroll", function() {
            if (fn) fn(_this);
        });
    };
    //滚动下拉刷新
    ScrollBar.prototype.ScrollPullDown = function(sOptions) {
        var _this = this.obj;
        _this.pulldown(sOptions);
    };
    exports.ScrollBar = ScrollBar;
    function getFontSize() {
        var doc = document, win = window;
        var docEl = doc.documentElement, resizeEvt = "orientationchange" in window ? "orientationchange" : "resize", recalc = function() {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            //如果屏幕大于750（750是根据我效果图设置的，具体数值参考效果图），就设置clientWidth=750，防止font-size会超过100px
            if (clientWidth > 750) {
                clientWidth = 750;
            }
            //设置根元素font-size大小
            docEl.style.fontSize = 100 * (clientWidth / 750) + "px";
        };
        //屏幕大小改变，或者横竖屏切换时，触发函数
        win.addEventListener(resizeEvt, recalc, false);
        //文档加载完成时，触发函数
        // doc.addEventListener('DOMContentLoaded', recalc, false);
        $(doc).ready(function() {
            recalc();
        });
    }
    exports.getFontSize = getFontSize;
    function getGoodsNo(url) {
        var reg = new RegExp("^YW[a-zA-Z0-9]{12,14}$");
        var aUrl = "";
        if (!url) return;
        if (url.indexOf("/") > -1) {
            aUrl = url.substr(0).split("/");
            for (var i = 0; i < aUrl.length; i++) {
                if (checkField(aUrl[i])) {
                    return checkField(aUrl[i]);
                } else if (checkField(aUrl[i]) == undefined) {
                    return false;
                }
            }
        } else {
            if (checkField(url)) {
                return checkField(url);
            } else if (checkField(url) == undefined) {
                return false;
            }
        }
        function checkField(_url) {
            var _aUrl = "";
            if (_url.length >= 14) {
                if (_url.indexOf("?") > 0) {
                    _aUrl = _url.split("?");
                    for (var i = 0; i < _aUrl.length; i++) {
                        if (reg.test(_aUrl[i])) {
                            return _aUrl[i];
                        }
                    }
                } else {
                    if (reg.test(_url)) {
                        return _url;
                    } else {
                        return false;
                    }
                }
            } else {
                return false;
            }
        }
    }
    exports.getGoodsNo = getGoodsNo;
    // 检测 安卓 ios 分享 大当家 链接跳转
    function JudgeAppHref(obj, oldH5) {
        var _href = "";
        var _Num = 0;
        var u = navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        // 返回首页操作
        var hrefToHome = [ "/", "sf://" ];
        var hrefName = [ "/h/goodspay/goodsView/", "sf://goodsDetail?goodsSn=" ];
        var sLocationArg = window.location.search.split("?")[1];
        var fxBtn = false;
        if (sLocationArg !== undefined) {
            if (sLocationArg.search("sell_member_id") > -1) {
                fxBtn = true;
            }
        }
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                _Num = 1;
                obj.each(function(i) {
                    _href = obj.eq(i).attr("_href");
                    // 检测回到首页
                    if (_href === "home") {
                        obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                    } else {
                        if (getGoodsNo(_href)) {
                            obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                });
            } else {
                obj.each(function(i) {
                    // 检测回到首页
                    _href = obj.eq(i).attr("_href");
                    if (_href === "home") {
                        AndroidReHome(obj.eq(i));
                    } else {
                        if (getGoodsNo(_href)) {
                            //要去掉a标签自带的href属性，因为这个跳转比点击事件要快，如果有这个属性在安卓上会跳转两次
                            obj.eq(i).removeAttr("href");
                            AndroidGoods(obj.eq(i), getGoodsNo(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                });
            }
        } else if (window.__wxjs_environment === "miniprogram") {
            obj.each(function(i) {
                // 如果有_href 这个自定义属性，_href 只有等于 home 或者 商品编号，就回到小程序页面；
                _href = obj.eq(i).attr("_href");
                if (_href) {
                    // 禁用掉 href
                    // obj.eq(i).attr("href", "javascript:void(0);");
                    obj.eq(i).removeAttr("href");
                    // 检测回到首页
                    if (_href === "home") {
                        minAppEven(obj.eq(i));
                    } else {
                        if (getGoodsNo(_href)) {
                            minAppEven(obj.eq(i), getGoodsNo(_href));
                        } else if (isDrawCouponLink(_href)) {
                            minAppEven(obj.eq(i), false, "/pages/home/drawCoupon/drawCoupon?ruleSign=" + isDrawCouponLink(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                }
            });
        } else if (fxBtn) {
            _Num = 0;
            obj.each(function(i) {
                _href = obj.eq(i).attr("_href");
                if (_href === "home") {
                    obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                } else {
                    if (getGoodsNo(_href)) {
                        obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href) + "?" + sLocationArg);
                    } else {
                        obj.eq(i).attr("href", _href + "?" + sLocationArg);
                    }
                }
            });
        } else {
            _Num = 0;
            obj.each(function(i) {
                _href = obj.eq(i).attr("_href");
                var appendData = _href.indexOf("?") > -1 ? "?" + _href.split("?")[1] : "";
                if (_href === "home") {
                    obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                } else {
                    if (getGoodsNo(_href)) {
                        if (oldH5 === "oldH5") {
                            obj.eq(i).attr("href", "/shop/goods/view/" + getGoodsNo(_href) + appendData);
                        } else {
                            obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href) + appendData);
                        }
                    } else {
                        obj.eq(i).attr("href", _href);
                    }
                }
            });
        }
    }
    exports.JudgeAppHref = JudgeAppHref;
    //判断是否是h5的领券页
    function isDrawCouponLink(url) {
        // var  reg = new RegExp("^YW[a-zA-Z0-9]{12,14}$");
        var ruleSignStr = "";
        if (!url) return false;
        if (url.indexOf("/coupon/drawCoupon") > -1) {
            ruleSignStr = url.split("ruleSign=")[1];
            if (ruleSignStr.indexOf("&") > -1) {
                var ruleSign = ruleSignStr.split("&")[0];
                return ruleSign;
            } else {
                return ruleSignStr;
            }
        } else {
            return false;
        }
    }
    exports.isDrawCouponLink = isDrawCouponLink;
    // 小程序事件处理
    function minAppEven(obj, arg, url) {
        obj.off("click");
        obj.on("click", function() {
            // console.log(arg)
            // 小程序物品详情
            if (arg) {
                wx.miniProgram.navigateTo({
                    url: "/pages/shopping/goodsDetail/goodsDetail?goodsSn=" + arg
                });
            } else if (url) {
                wx.miniProgram.navigateTo({
                    url: url
                });
            } else {
                wx.miniProgram.switchTab({
                    url: "/pages/home/home"
                });
            }
        });
    }
    // 安卓绑定点击事件
    function AndroidGoods(obj, arg) {
        obj.off("click");
        obj.on("click", function() {
            android.goodsDetail(arg);
        });
    }
    // 安卓绑定点击返回首页
    function AndroidReHome(obj) {
        obj.off("click");
        obj.on("click", function() {
            android.toMainAcivity();
        });
    }
    function removeArrayChildren(arr, val) {
        var index = arr.indexOf(val);
        if (index > -1) {
            arr.splice(index, 1);
        }
    }
    exports.removeArrayChildren = removeArrayChildren;
    // 弹框获取焦点后 页面高度调整
    function setFocusBodyScrollTop(timer, fn) {
        var cnt = 0;
        var oBody = $("body");
        timer = setInterval(function() {
            if (cnt < 3) {
                cnt++;
            } else {
                clearInterval(timer);
                timer = null;
                return;
            }
            oBody[0].scrollTop = oBody[0].scrollHeight;
            if (fn) fn();
        }, 300);
    }
    exports.setFocusBodyScrollTop = setFocusBodyScrollTop;
    function locationHref(href) {
        $("body").append($('<a href="' + href + '"><span id="locationHrefId"><span><a>'));
        $("#locationHrefId").click();
    }
    exports.locationHref = locationHref;
    // 检测 安卓 ios 隐藏指定对象
    function JudgeAppHide(ios, and, h5) {
        var u = navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                if (ios) ios();
            } else {
                if (and) and();
            }
        } else {
            if (h5) h5();
        }
    }
    exports.JudgeAppHide = JudgeAppHide;
    function isIphoneXsMinX() {
        return /iphone/gi.test(navigator.userAgent) && screen.height == 812 && screen.width == 375;
    }
    exports.isIphoneXsMinX = isIphoneXsMinX;
    function isIphoneXRXSMax() {
        return /iphone/gi.test(navigator.userAgent) && screen.height == 896 && screen.width == 414;
    }
    exports.isIphoneXRXSMax = isIphoneXRXSMax;
    /**
     * 判断是否是微信浏览器
     * @returns {Boolean}
     */
    function isWeiXin() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
        } else {
            return false;
        }
    }
    exports.isWeiXin = isWeiXin;
    /**
     * 判断是否是支付宝浏览器
     * @returns {boolean}
     */
    function isAlipayClient() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/AlipayClient/i) == "alipayclient") {
            return true;
        } else {
            return false;
        }
    }
    exports.isAlipayClient = isAlipayClient;
    /**
     * 判断是否是QQ内置浏览器
     * @returns {boolean}
     */
    function isQQClient() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/QQ/i) == "qq") {
            return true;
        } else {
            return false;
        }
    }
    exports.isQQClient = isQQClient;
    //XSS 前端过滤
    function XssCheck(str, reg) {
        return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g, function(a, b) {
            if (b) {
                return a;
            } else {
                return {
                    "<": "&lt;",
                    "&": "&amp;",
                    '"': "&quot;",
                    ">": "&gt;",
                    "'": ""
                }[a];
            }
        }) : "";
    }
    exports.XssCheck = XssCheck;
    /*
    * 判断用户是否安装app,已安装就跳app,未安装就正常跳h5页面
    * 因可能有安卓跳A页面，ios跳B页面的情况，所以两种终端的url分开写
    * androidUrl, iosUrl是跳的指定页面  比如'https://m.sfddj.com/coupon/toCouponCenter'
    * 如果没有指定页面(首页)就不填写或者填写空'' 如isHasApp('','',function(){})或者isHasApp()
    * */
    function isHasApp(androidUrl, iosUrl, fn) {
        var u = navigator.userAgent;
        var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
        //android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        if (u.search("origin/sfddjapp") == -1) {
            if (isAndroid) {
                // 在安卓的终端
                var HrefUrl = "";
                if (androidUrl && androidUrl != undefined && androidUrl != "") {
                    HrefUrl = "ddjapp://cn.dankal.sf/webpage?url=" + androidUrl;
                } else {
                    HrefUrl = "ddjapp://cn.dankal.sf/android";
                }
                // window.location.href = HrefUrl;
                locationHref(HrefUrl);
                setTimeout(function() {
                    if (fn) fn();
                }, 2e3);
            } else if (isiOS) {
                // 在ios的终端
                var HrefUrl = "";
                if (iosUrl && iosUrl != undefined && iosUrl != "") {
                    HrefUrl = "ddjapk://weburl?url=" + iosUrl;
                } else {
                    HrefUrl = "ddjapk://cn.dankal.sf";
                }
                window.location.href = HrefUrl;
                setTimeout(function() {
                    if (fn) fn();
                }, 2e3);
            }
        } else {}
    }
    exports.isHasApp = isHasApp;
    // 获取链接中的指定参数
    function getSearchString(key) {
        var str = window.location.search;
        str = str.substring(1, str.length);
        // 获取URL中?之后的字符（去掉第一位的问号）
        // 以&分隔字符串，获得类似name=xiaoli这样的元素数组
        var arr = str.split("&");
        var obj = new Object();
        // 将每一个数组元素以=分隔并赋给obj对象
        for (var i = 0; i < arr.length; i++) {
            var tmp_arr = arr[i].split("=");
            obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]);
        }
        return obj[key];
    }
    exports.getSearchString = getSearchString;
    // 跳转支付宝小程序 根据链接后面的 startAliapp 参数跳转
    function gotoMiniAlipay() {
        var _this = this;
        var startAliapp = getSearchString("startAliapp");
        if (!startAliapp) return;
        if (isWeiXin()) return;
        G_JSON_POST("/m/a/jumpLink/1.0/getJumpLink", {
            jumpLinkId: startAliapp
        }, function(data) {
            var _data = data.data;
            var _ret = data.ret;
            if (_ret.code == "0") {
                if (!_data) return;
                var s = document.createElement("a");
                s.href = _data;
                s.click();
            }
        });
    }
    exports.gotoMiniAlipay = gotoMiniAlipay;
    /**
     * 立即下单统计购买数据上传
     * @param order_sn
     * @param callback
     */
    function uploadCollection(payUrl, one_order_sn, callback) {
        // 立即购买的接口才记录
        if (payUrl !== "/shop/payment/orderPay") {
            return callback && typeof callback == "function" && callback();
        }
        var collectData = "/m/o/order/track/1.0/collectData";
        var sign = "";
        var query = window.location.search;
        query = query && query.trim();
        if (query) {
            query = query && query.split("&").filter(function(item) {
                return item.indexOf("goodMk") !== -1;
            });
            if (query && query[0]) {
                // 获取到的标识：F9VAGD597K1IIW0L
                sign = query[0].replace("goodMk=", "");
            }
        }
        if (one_order_sn && sign) {
            G_JSON_POST(collectData, {
                orderSn: one_order_sn,
                sign: sign
            }, function() {
                callback && typeof callback == "function" && callback();
            }, function() {
                callback && typeof callback == "function" && callback();
            });
        } else {
            callback && typeof callback == "function" && callback();
        }
    }
    exports.uploadCollection = uploadCollection;
});
define("static_v4/js/mod/baiduCount", [], function(require, exports, module) {
    var oBody = $("body");
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }
    function JudgeSource(ios, and, wxmin, wx, alipay, qq, h5) {
        var u = window.navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        var isWXMini = window.__wxjs_environment == "miniprogram";
        var ua = u.toLowerCase();
        var isWeiXin = ua.match(/MicroMessenger/i) == "micromessenger";
        var isAlipay = ua.match(/AlipayClient/i) == "alipayclient";
        var isQQ = ua.match(/QQ/i) == "qq";
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                if (ios) ios();
            } else {
                if (and) and();
            }
        } else if (isWXMini) {
            if (wxmin) wxmin();
        } else {
            if (isWeiXin) {
                if (wx) wx();
            } else if (isAlipay) {
                if (alipay) alipay();
            } else if (isQQ) {
                if (qq) qq();
            } else {
                if (h5) h5();
            }
        }
    }
    // 第三方统计的插件
    var TPLMethods = {
        userInfo: JSON.parse(getCookie("ddj-userInfo")),
        // 百度统计
        baidu: function() {
            /**
             *  百度统计
             */
            var sfddjUrl = "9a6219852c6bc360b517de9714e19810";
            //m.sfddj.com
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?" + sfddjUrl;
                // var s = document.getElementsByTagName("script")[0];
                // s.parentNode.insertBefore(hm, s);
                oBody.append(hm);
            })();
        },
        // gio 统计
        gio: function() {
            var _this = this;
            !function(e, t, n, g, i) {
                e[i] = e[i] || function() {
                    (e[i].q = e[i].q || []).push(arguments);
                }, n = t.createElement("script");
                // tag = t.getElementsByTagName("script")[0];
                // n.async = 1;
                n.src = ("https:" == document.location.protocol ? "https://" : "http://") + g;
                // tag.parentNode.insertBefore(n, tag)
                oBody.append(n);
            }(window, document, "script", "assets.growingio.com/2.1/gio.js", "gio");
            var _gioSetUserId = "";
            if (_this.userInfo) {
                if (_this.userInfo.memberId) {
                    _gioSetUserId = _this.userInfo.memberId;
                } else if (_this.userInfo.openId) {
                    _gioSetUserId = _this.userInfo.openId;
                } else {
                    _gioSetUserId = "";
                }
            }
            gio("init", "b665fa1721dac33b", {});
            // console.log(ddjhoc.userAction)
            // console.log(gio)
            // 给gio 传递用户信息
            gio("setUserId", _gioSetUserId);
            gio("send");
        }
    };
    // ZaneMa Testing
    $.getScript("/static_v4/js/plug/DDJStatistics.js", function(response, status) {
        ddjhoc.init(function() {
            // TPLMethods.baidu();
            TPLMethods.gio();
        });
    });
});